-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntNodeTest.java
More file actions
54 lines (34 loc) · 1.52 KB
/
Copy pathIntNodeTest.java
File metadata and controls
54 lines (34 loc) · 1.52 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
// CS 272 Intro to Data Structures
// Program Name: IntNode.java
// Author: Voltflip
// Date: 02/12/2019
// Purpose: The purpose of this program is to test the methods in IntNode.java
public class IntNodeTest {
public static void main (String[] args) {
// create several IntNode objects
IntNode head = new IntNode();
IntNode node2 = new IntNode();
IntNode node3 = new IntNode();
IntNode node4 = new IntNode();
IntNode node5 = new IntNode(20, null);
// set next and data instance variables using SetLink and SetData methods
head.setLink(node2);
node2.setData(2);
node2.setLink(node3);
node3.setData(3);
node3.setLink(node4);
node4.setData(4);
node4.setLink(node5);
//System.out.println(node2.getLink);
//System.out.println(node2.getData);
// not sure why these lines were giving me a "cannot find symbol" error
// test and print results of methods defined in IntNode.java file
System.out.println(head.listLength(head));
node3.addNodeAfterThis(7);
System.out.println(head.listLength(head));
System.out.println(head.search(head, 3));
System.out.println(head.toString());
node2.removeNodeAfterThis();
System.out.println(head.toString());
} // end main method
} // end IntNodeTest class