New electronic monitors are being installed on all rooms in the building and pass-cards are being issued to each employee in the building. Each time an employee enters or exits a room, the monitor adds the following information to a disk file:
The employee's ID number (4 digit number)
The room number (5 digit number, 2 digits for floor, 3 digits for room)
0 if the employee entered the room, or 1 if he exited the room.
At the end of the work day, the disk file contains a sequence of the above information for every employee's entry or exit to a room, in chronological order.
The building has at most 200 employees. The building has 110 rooms.
write a program on the computer that reads the daily disk file and generates some security reports. The security department is worried about someone forging a pass-card, so your program should print an error message if the same employee appears to be in two or more rooms at once. Also, there is worry that someone might tamper with the room monitors. So your program should print an error message if more than 10 employees appear to be in a room at the same time, or if an emloyee appears to exit a room that he is not in.
Finally, to help the security detectives, your program should produce two reports based on the day's activity. One report lists the names and ID numbers of all the employees who have been in each room. The other report lists all the rooms that have been visited by each employee. These two reports are calculated using data read from the disk file of monitor reports.
Should read three disk files:
A file of the current employees in a plain text disk file named "employee.txt". There are 3 data items about one employee in each record of this file, separated by spaces: an employee's ID number, the employee's first name and the employee's last name. There are never more than 200 employees. An example file with 3 employees is:
:
1001 Jim Smith
1002 John Brown
1004 Eric White
A file of the room numbers in the building is in text file named "rooms.txt". An example file with 3 rooms is:
03241
03242
03244
A file of monitor reports for the day is in a plain text file named "reports.txt". Each line of this file contains a report with 3 data items:
the employee ID
the room ID
0 if enter, or 1 if exit,
An annotated example file with 5 reports is:
1001 03241 0 employee 03241 enters room 1001
1002 03242 0 employee 03242 enters room 1002
1004 04170 0 employee 04170 enters room 1004
1002 03242 1 employee 03242 exits room 1002
1002 01420 0 employee 01420 enters room 1002
Okay so i'll be honest here, i'm pretty overwhelmed by this project. I know using classes will be easier, it's obviously going to use an array, a loop, and ifstream/ofstream in it. I'm just having problems putting it all together. And guide/pseudo code or any code at all would be helpful.
Here's the "lowdown" of what I think the classes might look like (haven't wrote code for the methods yet):
Employee.h Class:
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
class Room;
class Employee
{
public:
Employee(int ID, char *fname, char *lname, Room);
void readEmployee();
void enter();
private:
int ID;
char firstname[20];
char lastname[20];
};
#endif
Employee.cpp file
#include "Employee.h"
#include "Room.h"
Employee::Employee(int id, char *Fname, char *Lname, Room)
{
ID=id;
firstname[20]=Fname[20];
lastname[20]=Lname[20];
}
void enter() //reads the 0 or 1 to determine if entered or not
{
}
void readEmployee() //reads employee id and name
{
}
room.h
#ifndef Room_H
#define Room_H
class Employee;
class Room
{
public:
Room(int rmNUM);
void readRoom();
private:
int roomNumber;
};
#endif
room.cpp
#include "Room.h"
#include "Employee.h"
Room::Room(int rmNum)
{
roomNumber=rmNum;
}
void readRoom() //reads room number from file
{
}
Sorry for the long read but trying to give as much info as possible. Would like to know if i'm heading in the correct direction.
This post has been edited by JackOfAllTrades: 06 December 2012 - 05:05 PM
Reason for edit:: Split code based on files

New Topic/Question
Reply



MultiQuote






|