-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmain.cpp
More file actions
69 lines (54 loc) · 1.74 KB
/
main.cpp
File metadata and controls
69 lines (54 loc) · 1.74 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
//***********************************************************************************
// main.cpp
// LinkedList_Project
//
// Created by Karlina Beringer on June 12, 2014.
// This driver implements the LinkedList class.
//***********************************************************************************
#include "LinkedList.h"
using namespace std;
int main()
{
// STEP 1: Create some unlinked song nodes.
node * A = new node;
A -> song = "We Are";
A -> artist = "Vertical Horizon";
node * B = new node;
B -> song = "I Stand Alone";
B -> artist = "Godsmack";
node * C = new node;
C -> song = "Heir Apparent";
C -> artist = "Opeth";
node * D = new node;
D -> song = "Fear of the Dark";
D -> artist = "Iron Maiden";
node * E = new node;
E -> song = "Blue Monday";
E -> artist = "New Order";
node * F = new node;
F -> song = "The Moth";
F -> artist = "Aimee Mann";
// STEP 2: Build a list of three song nodes by appending to end of list.
LinkedList myList;
myList.insertNode(A, 1);
myList.insertNode(B, 2);
myList.insertNode(C, 3);
myList.insertNode(D, 4);
myList.printList();
// STEP 3: Insert a node into middle of list.
myList.insertNode(E, 2);
myList.printList();
// STEP 4: Insert node at the front of list.
myList.insertNode(F,1);
myList.printList();
// STEP 5: Remove the last node from the list.
myList.removeNode(6);
myList.printList();
// STEP 6: Remove the first node from the list.
myList.removeNode(1);
myList.printList();
// STEP 7: Remove a node from the middle of the list.
myList.removeNode(3);
myList.printList();
return 0;
}