Due Saturday, May 16 (or 23?), by 11:59pm (Midnight).
There is only one task and only one program to be submitted.
The program should start with a comment that contains your name and a short program description, for example:
/*
Author: Your Name
Description: HW 4. Project. Aperture Science HR.
.. you may add a more detailed description if it's necessary ..
*/
If a program does not do what it’s supposed to do (e.g. there are some bugs, it behaves differently, or maybe even does not compile), then its “incomplete” status must be clearly mentioned in the comment to the program. In this case, please briefly describe what is implemented, and what is not.
In accordance with the company anti-smoking policy, the Human Resources department of Aperture Science Laboratories wants to implement a new secret surveillance system for monitoring their personnel. This is probably an illegal thing to do, but the company lawyers believe that this is fine, and who are you to argue with that?
New smoke detectors and employee tracking devices have been setup and they already accumulate valuable data. However, there is no software to process these data yet. Congratulations, this is your job to write it, isn’t it exciting?!
The new software should be run from the terminal with 3 command line arguments:
./program employees.dat tracking.dat smoke.dat
If the number of command line arguments is less than 3, the program should exit immediately with an error message.
All arguments are file names. If the program cannot open these files, it should exit with an error message.
Employees data
# Number of employees
5
# EmployeeID FirstName LastName OfficeLocation
11 John Johnson 513
37 Michael Burke 11
24 Mary Clark 8
183 Vincent Cent 11
19 Roseline Harp 5
The OfficeLocation
field is the place where the employee works, and it’s expected that the employee
spends at least 75% of their time at this place.
Tracking data
All information from the employee tracking devices is listed here
# Number of entries
53
# Timestamp EmployeeID Location
105 11 61
105 24 6
105 37 17
105 19 8
106 37 17
106 24 5
106 19 8
106 11 62
106 183 20
107 37 17
...
(In this file, there is supposed to be exactly one record per timestamp for every employee, however, observe that due to infrequent tracking device failures, the locations of some employees are not reported at some timestamps, assume that their location is unknown at those time intervals)
Smoke detectors data
This datafile lists all locations where smoke was detected
# Number of entries
7
# Timestamp Location
106 62
107 213
110 11
112 11
...
The EmployeeID
and Location
values are positive integers, but they can be large.
Converting a string
to int
The easiest way to convert a string
to int
is to use the function stoi(s)
, however
it’s a part of the C++11 language standard, and to compile such code with g++
,
you have to run the compiler with an additional comamnd line option -std=c++11
, for example:
g++ -std=c++11 -o program program.cpp
>>> [employee.dat] [tracking.dat] [smoke.dat] <<<
Your code should be general, and should work for any dataset that complies with the file formats.
You only may assume that the “tracking” and “smoke” data are given sorted in the order of increasing Timestamp.
The program should provide the following Menu:
Main menu:
a - Report slackers.
b - Report suspected smokers.
c - Report employee's friends.
d - Identify broken tracking devices.
e - Exit
The program should read the user input, and if it’s not a
- e
, it should print the menu again.
If the user enters a
- d
the program should execute the corresponding section.
If the user input is e
, the program should exit.
Reporting slackers. Report those employees who spend at least 25% of the time not at their office.
After that the program should return to the main menu.
Reporting suspected smokers. The program should print the list of all people who spent at least 1% of the time in the rooms where smoke was detected.
Then the program should return to the main menu.
[Note the correction for finding smokers: use 1% instead of 2%]
Reporting employee’s friends. The program should ask for the first name and the last name of an employee. Then report an error message if the employee is not found, otherwise the program should print out the sorted list of at most 10 people with whom the inquired employee was most frequently observed together, and who don’t work at the same location with him or her.
The list of friends should be sorted according to the number of times they were seen together in the same room with the queried employee. If the number of possible friends is greater than 10, print only the information about 10 closest friends.
After that, the program returns to the main menu.
Identifying broken tracking devices. The program should find the list of all employees whose tracking devices malfunction and report at less than 95% of the timestamps.
After that, the program should return to the main menu.
The program should be implemented using at least 4-5 classes and/or structures, in at least 3 files (for example, one header file, one implementation file, and one main file).
Always try to separate your code into functions and classes where it’s possible, especially where it makes your program more readable, more modular, or where it lets you reuse the code.
Think well about the program design, which classes and functions you may find useful. Don’t afraid changing the code that’s already written if you see an opportunity to make it better, even if it requires rewriting certain parts, but improves the overall structure of your program.
The quality of the overall program organization will be graded as well as the correctness of the program implementation.
You should write a Makefile for building your program, or write exact instructions how to compile the code from the command line using g++
.