-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
74 lines (68 loc) · 1.82 KB
/
main.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
/*
* File: main.cpp
* Author: EvanMisshula
*
* Created on February 12, 2011, 4:43 PM
*/
#include <iostream>
#include <cstdlib>
#include "list.h"
using namespace std;
using std::cin;
using std::endl;
template< class T >
void testList( List< T > &listObject, const char *type )
{
cout<<"Testing a list of "<<type << " values\n";
instructions();
int choice;
T value;
do{
cout<<"? ";
cin>> choice;
switch (choice){
case 1:
cout<< "Enter "<< type << ": ";
cin>> value;
listObject.insertAtFront( value );
listObject.print();
break;
case 2:
cout<< "Enter "<< type << ": ";
cin>> value;
listObject.insertAtBack( value );
listObject.print();
break;
case 3:
if( listObject.removeFromFront( value))
cout<< value << " removed from list\n";
listObject.print();
break;
case 4:
if( listObject.removeFromBack( value ))
cout<< value << " removed from list\n";
listObject.print();
break;
}
} while ( choice != 5 );
cout << "End list test \n\n";
}
void instructions()
{
cout<<"Enter one of the following:\n"
<< " 1 to insert at begining of the list\n"
<< " 2 to insert at the end of the list\n"
<< " 3 to delete from begining of the list\n"
<< " 4 to delete from the end of the list\n"
<< " 5 to end list processing\n";
}
/*
*
*/
int main() {
List< int > integerList;
testList( integerList, "integer");
List< double > doubleList;
testList( doubleList, "double");
return 0;
}