This lab will help you practice with strings, classes, and parallel vectors.
Somehow, with not even a whole semester of programming under your belt, you've landed a job at tech support for a small research firm. Yesterday the company landed a military research project. To accommodate it, two labs have been sealed off and a security guard is to check off the researchers as they enter and leave each day.
Your project is to write a program the guard can run to help him/her track the times each researcher arrived and left. Your program will have 4 phases of operation: setup/initialization, arrival, departure, statistics reporting.
People keep wanting to call the functions localtime and asctime from the standard C library ctime here. Just don't! The goal of this program is for you to code this process yourself! (And asctime leaves a mess behind you would probably forget to clean up even if you knew how!)
The setup phase will entail the guard entering the names of all researchers scheduled to work that day. (All workers are required to phone in to the company answering service to report absenteeism so the guard will have this information when s/he comes on duty.) There aren't that many researchers assigned to the project — no more than 20 people are expected to be working on any given day.
During the arrival phase, the guard will select each researcher from the list your program provides. S/He can either type in the number of the person (you'll number the list as you print it out) or the person's name. When the guard selects a person who is in the list, record the time in a vector parallel to the one in which you recorded the researcher names for use later during the reporting phase. If the guard (accidentally) selects someone who isn't in the list, report this error to him/her. If the guard selects a person who has already arrived, ignore the new arrival and report to the guard that the person is already there.
The arrival phase ends when all the researchers have arrived or when the guard enters the name done.
The departure phase is very similar to the arrival phase, except you are recording the time the researcher left (and so it will need to go in a separate vector). (All researchers will not leave until the end of the day. The labs have bathroom facilities and lunch will be delivered to the guard who will send it into the lab for the researchers to eat. No one is allowed in or out until they are done for the day. The military does not condone 'family' emergencies.)
During the reporting phase, you'll print out a list of all the researchers, their arrival time, their departure time, and the number of hours (and minutes) they were there.
When searching for a researcher by name, you should ignore case — most guards aren't that precise about capitalizing peoples names.
The total time report should be given in both standard HH:MM as well as HH.dm formats (the second a fractional number; eight hours and forty-five minutes would be 8:45 and 8.75). Fractions of a minute are to be rounded off in the standard way — 30 seconds being the middle point.
How can you store a group of strings in an vector? How many dimensions will this require?
How can you have your name comparisons ignore capitalization?
How can you store the arrival and departure times?
How can you subtract times to find how long elapsed between them?
How can you convert raw seconds to a standard time format?
How can you round to the nearest minute?
This assignment is (Level 5).
Add (Level 2) to allow the guard to enter parts of a name. If the part they enter matches several researchers in the list, you should present them with a sub-list to choose from. If the part they enter matches the entire list, tell them to be more specific and re-print the list. Note: the comparisons should still be case insensitive.
How can you match just part of a string?
Add (Level 3) to use the given Time class to track arrival times and departure times. This will simplify your set of parallel vectors, but require you to add a method or two to the Time class. (Notably subtraction and get_as_dec_hour. But you should add all methods required to make it a complete set of functions.)
If you did all above options, this project could be worth as much as (Level 10).