-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSc2720_test1a.java
More file actions
99 lines (59 loc) · 1.96 KB
/
CSc2720_test1a.java
File metadata and controls
99 lines (59 loc) · 1.96 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
/*
* Program Name: Lab 6/test
* Name: Stephanie L. Wyckoff
* Date: 2/18/2017
* Course: Data Structures Lab
* Professor: Duan
* TA: Pelin Icer, Shubin Wu
*
* Description: Program creates new DoublyNameCardList and populates it with new NameCards. Program adds and deletes to and from the list with given data. Program checks if a NameCard exists
* already within the list. Program prints the list with each change and update.
*
* Input: none.
*
* Output: NameCard list
*/
public class test1a {
public static void printList(DoublyNameCardList list) {
for(int i = 0; i < list.count; i++) {
System.out.println("Name Card " + (i) + " is: " + list.get(i));
}
System.out.println();
}
public static void printReverseList(DoublyNameCardList list) {
for(int i = list.count-1; i >= 0; i--) {
System.out.println("Name Card " + (i) + " is: " + list.get(i));
}
System.out.println();
}
public static void main(String[] args) {
DoublyNameCardList myList = new DoublyNameCardList();
NameCard nc1 = new NameCard("Stephanie", 32, "Georgia State");
myList.addHead(nc1);
printList(myList);
NameCard nc2 = new NameCard("Brian", 31, "Georgia Tech");
myList.addTail(nc2);
printList(myList);
NameCard nc3 = new NameCard("Chris", 22, "GSU");
myList.addTail(nc3);
printList(myList);
NameCard nc4 = new NameCard("Togepi", 23, "Niantic");
myList.addHead(nc4);
printList(myList);
NameCard nc5 = new NameCard("Merill", 26, "Niantic");
myList.add(1, nc5);
printList(myList);
System.out.println("There are " + myList.count + " nodes in myList.\n");
printList(myList);
printReverseList(myList);
myList.deleteHead();
printList(myList);
myList.deleteTail();
printList(myList);
myList.delete(1);
printList(myList);
NameCard nc6 = new NameCard("Stephanie", 32, "Georgia Tech");
System.out.println(myList.exist(nc6) + "\n");
printList(myList);
}
}