-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCh17_JF.cpp
76 lines (58 loc) · 1.79 KB
/
Ch17_JF.cpp
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
/*
Student: Jeremy Farmer
Class: CSC 234-201
Assignment: Chapter 17 Homework
Purpose: This project makes a class for representing a singly linked list
with some functions, and a driver program to test the classes' functionality
*/
#include<iostream>
#include<string>
#include "NumberList_JF.h"
using namespace std;
int main() {
NumberList myList; // a linked list of integers
// these integers will be used to test the linked list
static const int SIZE = 5;
static const int sourceList[] = { 200, 42, 87, 301, 22 };
//
// test NumberList::appendNode
//
cout << "Appending sourceList to the linked list\n" << endl;
for (int i = 0; i < SIZE; i++)
myList.AppendNode(sourceList[i]);
myList.DisplayList(); // show the list
cout << "Appending sourceList (again) to the linked list\n" << endl;
for (int i = 0; i < SIZE; i++)
myList.AppendNode(sourceList[i]);
myList.DisplayList(); // show the list
//
// test NumberList::inserNode
//
cout << "Inserting sourceList into linked list\n" << endl;
for (int i = 0; i < SIZE; i++)
myList.InsertNode(i, sourceList[i]);
myList.DisplayList(); // show the list
//
// test NumberList::deleteNode
//
cout << "deleting at index 2" << endl;
myList.DeleteNode(2);
myList.DisplayList(); // show the list
//
// test NumberList::sort
//
cout << "Sorting in ascending order\n" << endl;
myList.SortList();
myList.SortList();
myList.DisplayList(); // show the list
//
// test NumberList::deleteDuplicates
//
cout << "Deleting duplicates\n" << endl;
myList.RemoveDuplicates();
myList.SortList(); //Sort again in case of any issues from Removing Duplicates
myList.DisplayList(); // show the list
// finished
system("pause");
return 0;
}