-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpa02.cpp
More file actions
81 lines (74 loc) · 2.47 KB
/
Copy pathpa02.cpp
File metadata and controls
81 lines (74 loc) · 2.47 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
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
main
====
Solve the main input and output here.
Within the main loop of your program, you must use the same polymorphic pointer to an Operating_system to manage multiple objects of type Cluster and Personal_surveillance_device.
Do not reference the objects directly.
Note: only a small fraction of your cpp implementations are tested in main.
**/
#include "managing_hierarchies.h"
int main()
{
bool keepGoing = true, numberSet = false;
int verNum;
long IMEI;
string deviceToManage, number, encrypt;
Operating_system *operptr;
while (keepGoing)
{
cout << endl << "What devices do you need to manage (choose one or enter 0 to exit): phone, cluster";
cin >> deviceToManage;
if (deviceToManage == "0")
{
cout << endl << "Exiting now" << endl;
return 0;
}
else if (deviceToManage == "phone")
{
cout << endl << "What is your IMEI?";
cin >> IMEI;
Personal_surveillance_device phone(IMEI);
operptr = ☎
cout << endl;
dynamic_cast<Personal_surveillance_device*>(operptr)->get_func_purpose();
cout << endl << "What is the version number of your operating system?";
cin >> verNum;
operptr->set_version_number(verNum);
cout << endl << "Your OS version number is: ";
operptr->get_version_number();
cout << endl << "What is your phone number?";
cin.ignore();
do {
getline(cin, number);
try
{
dynamic_cast<Personal_surveillance_device*>(operptr)->set_phone_number(number);
numberSet = true;
}
catch (MyException &e)
{
cout << endl << "That was not a valid phone number, please try again." << endl;
}
} while(!numberSet);
cout << "Your phone number is ";
dynamic_cast<Personal_surveillance_device*>(operptr)->get_phone_number();
cout << endl << "Would you like to encrypt your phone (type yes or no)?" << endl;
cin >> encrypt;
dynamic_cast<Personal_surveillance_device*>(operptr)->set_pretend_encryption();
}
else if (deviceToManage == "cluster")
{
Cluster aCluster;
operptr = &aCluster;
cout << endl;
dynamic_cast<Cluster*>(operptr)->get_func_purpose();
cout << endl << "What is the version number of your operating system?";
cin >> verNum;
operptr->set_version_number(verNum);
cout << endl << "Your OS version number is: ";
operptr->get_version_number();
cout << endl;
}
}
return 0;
}