Repository navigation
Expand file tree
/
Copy pathTests.java
More file actions
118 lines (105 loc) · 3.62 KB
/
Copy pathTests.java
File metadata and controls
118 lines (105 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import Lists.*;
import Queue.*;
import Stack.*;
class Tests {
public static int stack() {
// Tests for Stack.
//try {
Stack stack = new SimpleStack();
stack.push(100);
stack.push("A Fucking String");
stack.push(300);
stack.push(400);
System.out.println("Top element is " + stack.peek() + ".");
System.out.println(stack.pop() + " is removed.");
System.out.println(stack.peek());
System.out.println("Length is " + stack.getLength() + ".");
stack.clear();
assert stack.isEmpty();
System.out.println(stack);
//} catch (Exception e) {
// return 1;
//}
return 0;
}
public static int queue() {
// Tests for Queue.
//try {
Queue queue = new SimpleQueue();
queue.push(100);
queue.push("Strings!");
queue.push(300);
queue.push(400);
System.out.println("Next element is " + queue.peek() + ".");
System.out.println(queue);
System.out.println(queue.pop() + " is removed.");
System.out.println(queue);
queue.clear();
assert queue.isEmpty();
System.out.println(queue);
return 0;
//}catch (Exception e) {
// return 1;
//}
}
public static int singlyLinkedList() {
// Tests for singly linked list.
// try {
LinkedList ll = new SinglyLinkedList();
ll.addAtStart(200);
ll.addAtStart(100);
ll.addAtStart("Now I can add strings too!");
ll.addAtEnd(300);
ll.addAtEnd(400);
System.out.println(ll.getAt(0));
System.out.println(ll.getAt(1));
System.out.println(ll);
ll.removeAt(3);
System.out.println(ll);
ll.clear();
System.out.println(ll);
return 0;
//} catch (Exception e) {
// return 1;
//}
}
public static int doublyLinkedList() {
// Tests for doubly linked list.
// try {
LinkedList dll = new DoublyLinkedList();
dll.addAtStart(200);
dll.addAtStart(100);
dll.addAtStart("Now I can add strings too!");
dll.addAtEnd(300);
dll.addAtEnd(400);
System.out.println(dll.getAt(0));
System.out.println(dll.getAt(1));
System.out.println(dll);
dll.removeAt(3);
System.out.println(dll);
dll.clear();
System.out.println(dll);
return 0;
//} catch (Exception e) {
// return 1;
//}
}
public static void main(String[] args) {
// Prompt user for data strcuture they want to perform actions on;
// TODO Choose file on which tests will take place on the go...
System.out.println("-------------");
System.out.println("Performing tests on Simple Stack: \n");
Tests.stack();
System.out.println("\n-------------");
System.out.println("Performing tests on Queue: \n");
Tests.queue();
System.out.println("\n-------------");
System.out.println("Performing tests on Singly Linked List: \n");
Tests.singlyLinkedList();
System.out.println("\n-------------");
System.out.println("Performing tests on Doubly Linked List: \n");
Tests.doublyLinkedList();
System.out.println("\n-------------");
System.out.println("Tests done. Good Work!\n");
}
}