-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinkedList.java
More file actions
37 lines (30 loc) · 1 KB
/
LinkedList.java
File metadata and controls
37 lines (30 loc) · 1 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
public class LinkedList {
private Node headNode;
public void addNode(String sAirportID){
//1. Create new node and fill in date.
Node oNewNode = new Node();
//2. Assign the head node to new node's nextnode variable.
oNewNode.nextNode = headNode;
//3. Set Headnode to new node.
headNode = oNewNode;
}
public Node removeHeadNode(){
//1. Set temp node to head node.
Node oReturnNode = headNode;
//2. Set headNode to head node's next node.
if(headNode != null){ headNode = headNode.nextNode;}
//3. Return temp node.
return oReturnNode;
}
public void addHeadNode(int x, int y){
//1. Create new node
Node city = new Node();
//2. Set x and y on this new node
city.xPosition = x;
city.yPosition = y;
//3. Set next node on this new node to head node
city.nextNode = headNode;
//4. Set head node to this new node
headNode = city;
}
}