![]() |
| | #1 |
| Guest
Posts: n/a
| Phone Class 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 } |
|
| | #2 |
| Super Moderator Join Date: Sep 2001
Posts: 4,680
| Well, a lot of people get a little ticked off if you don't use <code> tags, so get ready for some of those negative comments..... I don't know why it matters..... all it does is indent it.... Anyway - for starters - there'll be problems with people getting your code because one of the class names (or part of it) was turned into a smiley. Other than that, what exactly IS your question? |
| sean is offline | |
| | #3 |
| Guest
Posts: n/a
| sorry, I do not know what code tags are or how to use them. Please explain if you don't mind. My main concern in my program is the member functions. I can not seem to put them into the program. For instance, the Void Dial(int, int) and Void Checkmess(int), I know what needs to be done in the program but just can not code it. I really do not know how to create the member functions. If you can help me create better member function I think I can precede. right now I am stuck. Thanks |
|
| | #4 |
| ¡Amo fútbol! Join Date: Dec 2001
Posts: 2,121
| [c o d e] [/c o d e] without the spaces will give code tags. |
| golfinguy4 is offline | |
| | #5 | |
| Registered User Join Date: Mar 2002
Posts: 23
| Quote:
Code: class controlbox{
private:
phone system[10];
int CM; // checking messages
int HU; // hang up
int busy; // line busy
int status;
public:
void Dial(int,int);
void Checkmess(int);
void Hangup(int);
};
void controlbox::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"
}
}//end Dial(int,int)
[edit]the smiley face is ": D" without the space...its a smiley face if you put them together on these boards..[/edit] -Dennis | |
| prophet is offline | |
| | #6 |
| Guest
Posts: n/a
| Ok I see... I guess you have to put the return type, the class name, the object, then the parameters. Like the function checkmess, I would put void controlbox::Checkmess(int CM) { CM = 1; cout << " Line is busy \n"; } But does the functions work for the Dial command and checkmess? Also how can I create member functions for HU<phone> to hang up a phone and automatically hung up the other persons phone? -Nicky |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Class design problem | h3ro | C++ Programming | 10 | 12-19-2008 09:10 AM |
| Specializing class | Elysia | C++ Programming | 6 | 09-28-2008 04:30 AM |
| Screwy Linker Error - VC2005 | Tonto | C++ Programming | 5 | 06-19-2007 02:39 PM |
| Creating a database | Shamino | Game Programming | 19 | 06-10-2007 01:09 PM |
| Abstract class problem | VanJay011379 | C++ Programming | 9 | 07-31-2002 01:30 PM |