unsensible 11 Newbie Poster

So i've been working on this program for a couple of days and just cannot figure it out for the life of me. I'm fairly new to classes and methods so I think that's probably why.

Here's the lowdown of the project:

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

To sum it up, I need to read these files, check for mistakes, then output two reports based upon the activity for the day. The main problem i'm having is using the class to store them in an array.

I want to use the Employee class to store both the name and the id of the individuals. But doing so means I have to use a default constructor. I've been considering just getting rid of classes altogether but I heard that is the easiest way.

Anyways, here's what I have so far

main:

// read monitor reports file

#include "Employee.h"
#include "Room.h"
#include <iostream>
#include <fstream>
#include <cstdlib>

using namespace std;

Employee emp[200];
//Employee variables
 int e[200];
 //string emp;
 int empid;
 char ename[20];
 char str[80];
//Room variables
 int r[110];
 int roomid;
 int n;
 int j;
//Records variables
 int enter_exit;
 void *gotit;

void readReports()
{
int i=0;
  // specify the name of the file to read:  reports.txt
  ifstream infile("reports.txt");

  if (!infile) {
     cerr<<"Can't find reports.txt file. Bye."<<endl;
    exit(1); 
  }
  // read each monitor reports
  while(true) {  // at most 400 reports.
     // read one more report
     gotit = infile>>empid>>roomid>>enter_exit;
     if (!gotit) break;   // there are no more  records

     // got another record, print out the information.
     //cout<<id<<" "<<roomid<<" "<<enter_exit<<endl;
     // here save the report data in a "report" object.
  }
}

void readRooms()
{
    int i = 0;

    ifstream inFile("rooms.txt");

    if(!inFile)
    {
        cerr<<"Can't find room.txt file. Bye.";
        exit(1);
    }
     while(true) {  // at most 110 rooms.
     // read one more room
     gotit = inFile>>roomid;
     if (!gotit) break;   // there are no more rooms

     // got another record, print out the information.
     r[i]=roomid;
     i++;

  }

}
void readEmployee()
{
  int i = 0;
  ifstream inFile("employees.txt");

  if(!inFile)
  {
      cerr<<"Can't find employee.txt file. Bye."<<endl;
      exit(1);
  }
  while (true)
  {

      inFile.get(str, 80, ' '); 

      if (inFile.eof()) break;
      empid = atoi(str); //convert empid to int
      inFile.get();

      inFile.getline(ename,20); //read the last line (first and last name)
      if (inFile.eof()) break;

      string sname(ename); //convery c-string to string
      emp[i].Eset(sname,empid);
       i++;
  }

}

int main() {

    readEmployee();
    readRooms();
    readReports();

    system("PAUSE");

}



#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include<string>

using namespace std;

class Employee
{
public:
    Employee();//int empID, string name);
void Eset(string name, int empID);

private:
    int empID;
    string name;
    int id;
    string n;

};
#endif




#include "Employee.h"
#include <iostream>
#include <string>

using namespace std;

Employee::Employee()//(int id, string n)
{
    //name=n;
    //empID=id;
}

void Employee::Eset(string name, int empID)
{
    name=n;
    empID=id;
}

It compiles. But all it does is read all the files and store them in arrays. However, when I try to print out the Eset method it just prints a bunch of 0's. I'm obviously doing something wrong but can't figure it out. Sorry if it's tl;dr.

Thanks for any help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.