Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,673 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,175 people online right now. Registration is fast and FREE... Join Now!




Storing data from inherited classes

 
Reply to this topicStart new topic

Storing data from inherited classes, Desperately need help soon

falconheart
post 4 Sep, 2007 - 06:53 AM
Post #1


New D.I.C Head

*
Joined: 14 Apr, 2007
Posts: 8


My Contributions


I'm a CS student, and my assignment is due and I have no idea what to do next! I've looked online and throughout my textbook and I can't find the answer.. So I thought maybe you all could help me out. I dont have much time left to submit this, so I sincerely hope you can.
This information isnt covered in my textbook.. I've written the inherited classes as directed but I don't know what to do now. I'm supposed to be able to create a sort of database of information using these classes, and then be able to search it and so on and so forth. I can't find anything that will work to store the data. I've tried structs, pointers, arrays, etc and all I get are compiler errors or program crashes. I'll post my code up to this point, as well as the assignment itself incase I'm just mental and missed something.
The assignment is as follows:
--
The fictitious company Global Tech Industries needs a system that tracks employees and clients.
All employees have a 9-digit employee identification number, first name and last name. Employees who work in the high-security laboratory are classified as secure employees. A secure employee has a clearance level of 1-9. Other employees may belong to an internal tech-support group and are classified as support employees. A support employee is on 24-hour call and thus the employee’s pager number (a 10-digit number which includes an area code) must be stored. Note that not all employees are classified as support or secure.
All clients have a 5 character client identification code that may include letters and digits, and a first name and last name.
For this assignment, use C++ classes object-oriented design to create a program to help Global Tech Industries track employees and clients. You should create an abstract base class for a person that encompasses the common data of employees and clients, then create classes for employees and clients as descendants. Then, create classes for secure and support employees as descendants of employee. Finally, create structures to store and retrieve employees and clients, and a program that allows the user to interact with these structures. You should be able to:
Enter an employee into the system. If the employee is classified as “secure” or “support,” then additional information must be requested and stored.
Enter a client into the system.
Retrieve an employee or client by entering the identification number or code.
List all employees or clients (not in any particular order).
For this assignment, you are not required to store the employee or client information in a file. You can assume the maximum number of employees and clients is fixed at 100 each.
-----

and here's my code:

CODE

#include <iostream>
#include <cstdlib>
#include <cstring>

using namespace std;




//-----------------------------\\
//            Person           \\

class Person
{
public:
    Person();
    Person(string tempName);
    virtual void setName(string tempName);
    virtual string getName();

private:
    string Name;
};

Person::Person(string tempName)
{
    setName(tempName);
}

void Person::setName(string tempName)
{
    Name = tempName;
}

string Person::getName()
{
    return Name;
}

//-----------------------------\\
//          Employee           \\

class Employee : public Person
{
public:
    Employee(string tempName, int tempID);
    virtual void setID(int tempID);
    virtual int getID();

private:
    int ID;
};


Employee::Employee(string tempName, int tempID)
: Person(tempName)
{
    setID(tempID);
}

void Employee::setID(int tempID)
{
    ID = tempID;
}

int Employee::getID()
{
    return ID;
}

//--------------------------------------\\
//              SECURE                  \\

class Secure : public Employee
{
public:
    Secure(string tempName, int tempID, int clearance);
    void setClearance(int clearance);
    int getClearance();
private:
    int clearancelevel;
};

Secure::Secure(string tempName, int tempID, int clearance)
: Employee(tempName, tempID)
{
    setClearance(clearance);
}

void Secure::setClearance(int clearance)
{
    clearancelevel = clearance;
}

int Secure::getClearance()
{
    return clearancelevel;
}

//--------------------------------------\\
//              Support                  \\

class Support : public Employee
{
public:
    Support(string tempName, int tempID, int temppager);
    void setPagerNumber(int temppager);
    int getPagerNumber();
private:
    int pagerNumber;
};

Support::Support(string tempName, int tempID, int temppager)
: Employee(tempName, tempID)
{
    setPagerNumber(temppager);
}

void Support::setPagerNumber(int temppager)
{
    pagerNumber = temppager;
}

int Support::getPagerNumber()
{
    return pagerNumber;
}

//--------------------------------------\\
//              CLIENT                  \\

class Client : public Person
{
public:
    Client(string tempName, string tempID);
    void setID(string tempID);
    string getID();

private:
    string ID;
};


Client::Client(string tempName, string tempID)
: Person(tempName)
{
    setID(tempID);
}

void Client::setID(string tempID)
{
    ID = tempID;
}

string Client::getID()
{
    return ID;
}


(main is blank because I haven't written the rest of the program yet)

help! please! anybody?
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 4 Sep, 2007 - 07:00 AM
Post #2


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,178



Thanked 33 times

Dream Kudos: 25
My Contributions


Can you post the errors you are receiving?
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/23/08 06:16AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month