| | |
simulating a handheld texting device
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2009
Posts: 4
Reputation:
Solved Threads: 0
I have a homework assignment that I'm stuck on...i have to make a program that works like text messaging on a cell phone. It uses three classes, keypad, display, and texter.
keypad - is the keypad. it allows the user to enter all alpha-numeric characters. the class handles input. it can include cin statements (like cin.getine) but no cout statements
display - it simulates a display on the texting device. It is responsible for the output and can only contain cout statments
texter - it's the "brain" It is responsible for orgainizng functions of the keypad and display classes so the user can send texts. the class should have one member variable which is a keyboard object and one member variable that's a display object. It is supposed to call functions on the objects to facilitate texting. This class should have no cin or cout statements
The code in main only does three things:
Declare a Texter object
Call a "menu" method on the Texter object
At the end of main, return 0
The texter screen should look like this:
Main Menu:
1. send Text Message
2. Turn off
Input your choice:
If the user chooses 1, the Texter should show
Input phone number: 1234567(the input)
Input Message: Hey! (the input)
Message sent successfully.
(Print main until the user chooses the second option)
Here is my code thus far:
* i haven't started main yet. I want to get my classes done first
* one question, which files should I include in my classes...i don't know if i should include all of the ones i did include or if i only need the .cpp files
*any help is greatly appreciated
keypad - is the keypad. it allows the user to enter all alpha-numeric characters. the class handles input. it can include cin statements (like cin.getine) but no cout statements
display - it simulates a display on the texting device. It is responsible for the output and can only contain cout statments
texter - it's the "brain" It is responsible for orgainizng functions of the keypad and display classes so the user can send texts. the class should have one member variable which is a keyboard object and one member variable that's a display object. It is supposed to call functions on the objects to facilitate texting. This class should have no cin or cout statements
The code in main only does three things:
Declare a Texter object
Call a "menu" method on the Texter object
At the end of main, return 0
The texter screen should look like this:
Main Menu:
1. send Text Message
2. Turn off
Input your choice:
If the user chooses 1, the Texter should show
Input phone number: 1234567(the input)
Input Message: Hey! (the input)
Message sent successfully.
(Print main until the user chooses the second option)
Here is my code thus far:
C++ Syntax (Toggle Plain Text)
// keypad.h #include <string> using namespace std; class keypad { private: long int number; string message; public: long int InputNumber(); string InputMessage(); }; // keypad.cpp #include “keypad.h” #include <string> using namespace std; long int keypad::InputNumber() { cin >> number; return number; } string keypad::InputMessage() { cin >> message; return message; } // display.h #include <string> #include “keypad.h” #include “keypad.cpp” using namespace std; class display { private: long int number; string message; public: void InputPhone(); void InputMessage(); }; // display.cpp #include “keypad.h” #include “keypad.cpp” #include <string> void display::InputPhone() { cout << “Input phone number: “; } void display::InputMessage() { cout << “Enter your message: “; } // text.h #include “display.h” #include “display.cpp” #include “keypad.h” #include “keypad.cpp” class text { private: public: keypad key(); Display disp(); }; // text.cpp #include “display.h” #include “display.cpp” #include “keypad.h” #include “keypad.cpp” #include “text.h” void text::disp.InputPhone() { } void text::key.InputNumber() { } void text::disp.InputMessage() { } void text::disp.InputPhone() { } // textMain.cpp #include “display.h” #include “display.cpp” #include “keypad.h” #include “keypad.cpp” #include <iostream> using namespace std; text Texter
* i haven't started main yet. I want to get my classes done first
* one question, which files should I include in my classes...i don't know if i should include all of the ones i did include or if i only need the .cpp files
*any help is greatly appreciated
A class consists (most of the time) out of 2 parts: a definition and an implementation.
The definition defines the types and parameters of functions, as well as member variables. This is the header file.
The implementation gives code to the definition: it implements the definition.
Your assignment is to write an implementation given a specific definition: you're told what the objects should be able to do, but how they do it, how you implement those functions, is up to you.
Here is a simple example of a header file, it's implementation and it's use in a program. Note that the link uses
http://functionx.com/cpp/examples/simpleclass.htm
The definition defines the types and parameters of functions, as well as member variables. This is the header file.
The implementation gives code to the definition: it implements the definition.
Your assignment is to write an implementation given a specific definition: you're told what the objects should be able to do, but how they do it, how you implement those functions, is up to you.
Here is a simple example of a header file, it's implementation and it's use in a program. Note that the link uses
void main() something you should never do. http://functionx.com/cpp/examples/simpleclass.htm
![]() |
Other Threads in the C++ Forum
- Previous Thread: C++ messagebox and tutors ..
- Next Thread: Please help with some C2447 errors
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game generator getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





