I really need help with classes, I do not know if its actually the classes or functions. But I need help with my project for my class. The problems is to design a program for a phone system. The system consists of 10 phones numbered 0-9. Each phone submits requests to the control box that attempts to execute the request. We need to write a control Box software and the phone software to manage the calls requests come into the control box.
DL<from><to> - This request attempts to dial <from> one phone <to> another.
HU<phone> - This request hangs up a phone. When two people are talking and one hangs up the other phone automatically hangs up.
CM<phone> - This request starts someones personal phone messages and should give callers a busy signal.
ST - This request reports the number of times a person has listened to their messages and how many internal phone calls have been made.
The program will read from a data file
example:
DL 4 6 //complete call
DL 1 4 //should get busy signal
CM 9 //phone 9 checking their messages
HU 9 //9 hangs up from checking messages
HU 4 // 4 hangs up from 6 and 6 should automatically hang up
I know this is kind of long but I really need help. The last programming class I took was two years ago, so please keep the negative comments away and help if you can. Thanks
This is what I came up with so far.
#include <fstream.h>
#include <stdlib.h>
#include <string.h>
class phone{
private:
int nCompcalls; //count number of completed calls
int nCheckmess; //count number of checked messages
int Talking; // phone availability
public:
phone();
};
phone:hone()
{
nCompcalls = 0;
Talking = -1; // Talking = -1 when line is available and = the number of person talking to when talking
ncheckmess = 0;
}
class controlbox{
private:
phone system[10];
int CM; // checking messages
int HU; // hang up
int busy; // line busy
int status; // number times checked phone messages and internal calls
public:
void Dial(int,int);
void Checkmess(int);
void Hangup(int);
};
void Dial(int from, int to)
{
if (to == -1) // if to is -1 or available
{
to = from; // make to equal to from
cout << "Completed Call \n"
}
else{
cout << " Unable to complete call \n";
}
}
void Checkmess(int CM)
{
CM = 1;
cout << " Line is busy \n";
}
//missing functions
void main(void)
{
ifstream tfile;
ofstream ofile;
tfile.open("Project3Data.txt");
ofile.open("output.txt");
if(tfile.fail ())
{
cout << " Unable to open file.";
exit(1);
}
//missing information in main
}