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:

// 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 :)

Header files such as string need to be included in the header file and in the .cpp file. We call these 2 files (header and .cpp) the definition of a class and its implementation when used to form a class.

If you want more help, ask more questions, but try to keep them specific.

What goes in the text.cpp file with the variables? Is that where I put the objects then their function?

ie:key.InputPhone

but I'm not sure if I did those right...i don't know how to do it without cin or cout statements.

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 void main() something you should never do.

http://functionx.com/cpp/examples/simpleclass.htm

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.