-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheduler.cpp
128 lines (112 loc) · 2.45 KB
/
scheduler.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
Scheduler implementation
Ben Rimedio - 11/17/2021
CS202 - Fall 2021
Instructor: Karla Fant
This is the implementation of the Scheduler client class.
*/
#include "scheduler.h"
//Default constructor:
Scheduler::Scheduler() {}
//Copy constructor:
Scheduler::Scheduler(const Scheduler& source)
{
distances = source.distances;
pettables = source.pettables;
aquatics = source.aquatics;
}
//Destructor:
Scheduler::~Scheduler() {}
//Assignment operator:
Scheduler& Scheduler::operator= (const Scheduler& to_copy)
{
if(this != &to_copy)
{
distances = to_copy.distances;
pettables = to_copy.pettables;
aquatics = to_copy.aquatics;
}
return *this;
}
//Input and insert distance:
void Scheduler::insert_distance(void)
{
distances.insert();
}
//Input and insert aquatic:
void Scheduler::insert_aquatic(void)
{
aquatics.insert();
}
//Input and insert pettable:
void Scheduler::insert_pettable(void)
{
pettables.insert();
}
//Input and remove aquatic:
bool Scheduler::remove_aquatic(void)
{
return aquatics.remove();
}
//Input and remove pettable:
bool Scheduler::remove_pettable(void)
{
return pettables.remove();
}
//Input and remove aquatic by index:
bool Scheduler::remove_index_aquatic(void)
{
size_t to_remove;
try
{
std::cout << "Which index would you like to remove?: ";
std::cin >> to_remove;
if(!std::cin)
throw false;
std::cin.clear();
std::cin.ignore(MAX_STREAM, '\n');
return aquatics.remove(to_remove, aquatics[to_remove]);
}
catch(bool err)
{
std::cin.clear();
std::cin.ignore(MAX_STREAM, '\n');
return err;
}
}
//Input and remove pettable by index:
bool Scheduler::remove_index_pettable(void)
{
size_t to_remove;
try
{
std::cout << "Which index would you like to remove?: ";
std::cin >> to_remove;
if(!std::cin)
throw false;
std::cin.clear();
std::cin.ignore(MAX_STREAM, '\n');
return pettables.remove(to_remove, pettables[to_remove]);
}
catch(bool err)
{
std::cin.clear();
std::cin.ignore(MAX_STREAM, '\n');
return err;
}
}
//Display distances:
void Scheduler::display_distance(void)
{
distances.display();
}
//Display aquatics:
void Scheduler::display_aquatic(void)
{
aquatics.display();
}
//Display pettables:
void Scheduler::display_pettable(void)
{
pettables.display();
}