C++ Problem You have been tasked with implementing an agenda program. The user s
ID: 3698090 • Letter: C
Question
C++
Problem
You have been tasked with implementing an agenda program. The user should be able to add items to their agenda, complete the appointment that will occur next, view their agenda, and toggle between viewing the agenda in 24-hour (military) time and 12-hour time.
Specifications:
Implement two structs: Time, and Date.
Implement two classes: Appointment, and Agenda.
The Date and Time structs should be able to detect when they’re given bad values (impossible dates and times) and use a default value in such a case.
The struct Time should have the following attributes:
int hour
int minute
and the following methods:
Time()
Time(int h, int m)
string getTimeString()
Calls the other function of the same name with military=true
string getTimeString(bool military)
Returns a string containing the time in the format “hh:mm” and adds an am/pm if requested.
void print()
Calls the other function of the same name with military=true
void print(bool military)
Outputs the string generated by getTimeString and respects the 24-hour time request
The struct Date should have the following attributes:
int year
int month
int day
and the following methods:
Date()
Date(int y, int m, int d)
string getDateString()
Returns a string containing the date in the format “yyyy-mm-dd”
void print()
Outputs the string generated by getDateString.
The Appointment class should have the following attributes:
Date date
Time start
Time end
string title
string guest
and the following methods:
Appointment()
Appointment(Date d)
void print()
Calls the other print function with military=true.
void print(bool military)
Prints all of the relevant info about the appointment as shown in the sample output. Don’t output anything about guests if there aren’t any guests.
long int getDateTimeRaw()
Returns a long int to be used for comparing two date/times against each other to see which comes first. You’ll need to determine an algorithm that is appropriate here.
void setStartTime(Time t)
Sets the appointment’s start time.
void setEndTime(Time t)
Sets the appointment’s end time.
void setTitle(string t)
Sets the appointment’s title.
void setGuest(string g)
Sets the appointment’s guestlist.
The Agenda class should have the following attributes:
vector appointments
bool military
and the following methods:
Agenda()
void addAppointment()
Adds an appointment. Insert the appointment into the appointments vector in such a way that the vector is always sorted in chronological order. Use the getDateTimeRaw function from the Appointment class to date/time of two appointments to see which comes first.
void completeNextAppointment()
Removes the earliest occurring event from the agenda (it’ll be at the beginning of the appointments vector).
void toggleMilitary()
Toggle the agenda’s 24-hour format boolean variable. It lets the user know what the current setting is after toggling.
void print()
Prints all of the appointments in the agenda. Because the appointments vector is sorted chronologically, this will print each event in chronological order.
Sample Output:
Assume all italicized text is stuff the user typed into the program:
1. View agenda
2. Add item to agenda
3. Complete next agenda item
4. Toggle 24-hour time
5. Quit
> 1
No appointments currently on the agenda
1. View agenda
2. Add item to agenda
3. Complete next agenda item
4. Toggle 24-hour time
5. Quit
> 2
Enter the year, month, and date separated by spaces: 2016 05 10
Enter the start hour and minute separated by spaces: 16 30
Enter the end hour and minute separated by spaces: 19 00
Enter an event title: EECS 138
Final Exam Will there be any guests (y or n)? n
Event added.
1. View agenda
2. Add item to agenda
3. Complete next agenda item
4. Toggle 24-hour time
5. Quit
> 1
(1) EECS 138 Final Exam on 2016-05-10 from 16:30 to 19:00
1. View agenda
2. Add item to agenda
3. Complete next agenda item
4. Toggle 24-hour time
5. Quit
> 2
Enter the year, month, and date separated by spaces: 2016 05 05
Enter the start hour and minute separated by spaces: 23 59
Enter the end hour and minute separated by spaces: 23 59
Enter an event title: EECS 138 - Project 5 Due
Will there be any guests (y or n)? n
Event added.
1. View agenda
2. Add item to agenda
3. Complete next agenda item
4. Toggle 24-hour time
5. Quit
> 2
Enter the year, month, and date separated by spaces: 2016 05 04
Enter the start hour and minute separated by spaces: 13 0
Enter the end hour and minute separated by spaces: 15 0
Enter an event title: Last Office Hour for 138
Will there be any guests (y or n)? y
Enter the name of the guest. If there are several, enter all the names separated by commas: Theodore Lindsey
Event added.
1. View agenda
2. Add item to agenda
3. Complete next agenda item
4. Toggle 24-hour time
5. Quit
> 1
(1) Last Office Hour for 138 on 2016-05-04 from 13:00 to 15:00 with Theodore Lindsey
(2) EECS 138 - Project 5 Due on 2016-05-05 from 23:59 to 23:59
(3) EECS 138 Final Exam on 2016-05-10 from 16:30 to 19:00
1. View agenda
2. Add item to agenda
3. Complete next agenda item
4. Toggle 24-hour time
5. Quit
> 3
Last Office Hour for 138 on 2016-05-04 from 13:00 to 15:00 with Theodore Lindsey
...Removed
1. View agenda
2. Add item to agenda
3. Complete next agenda item
4. Toggle 24-hour time
5. Quit
> 1
(1) EECS 138 - Project 5 Due on 2016-05-05 from 23:59 to 23:59
(2) EECS 138 Final Exam on 2016-05-10 from 16:30 to 19:00
1. View agenda
2. Add item to agenda
3. Complete next agenda item
4. Toggle 24-hour time
5. Quit
> 4
12-hour time turned on
1. View agenda
2. Add item to agenda
3. Complete next agenda item
4. Toggle 24-hour time
5. Quit
> 1
(1) EECS 138 - Project 5 Due on 2016-05-05 from 11:59 pm to 11:59 pm
(2) EECS 138 Final Exam on 2016-05-10 from 04:30 pm to 07:00 pm
Codes:
Explanation / Answer
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.