C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-29-2002, 06:03 PM   #1
Unregistered
Guest
 
Posts: n/a
Phone Class

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

}
  Reply With Quote
Old 03-29-2002, 07:23 PM   #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   Reply With Quote
Old 03-29-2002, 07:54 PM   #3
Unregistered
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
  Reply With Quote
Old 03-29-2002, 10:00 PM   #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   Reply With Quote
Old 03-29-2002, 10:34 PM   #5
Registered User
 
Join Date: Mar 2002
Posts: 23
Quote:
Originally posted by Unregistered
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
Well its almost the same as the constructor for example:
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)
I think that is what you wanted..

[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   Reply With Quote
Old 03-30-2002, 07:42 AM   #6
Unregistered
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
  Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 04:01 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22