I need help getting started and understanding how to do this assignment:
Assignment 3
Roger has a very active social life, and is having problems keeping his phone numbers in order. Each time he gets a new cell phone, he loses many of his phone number, so he would like a program with this he can store numbers on his computer.
Phone Number class
The following UML diagram describes members of this class:
PhoneNumber
- countryCode:int // 2 digit country code
- areaCode:int // 3 digit area code
- number:int // 7 digit phone number
- type:char // 'H', 'C', or 'B', for home, cell or business line
- year:int // year that the entry was made
+ PhoneNumber( ) |
+ PhoneNumber (int ccode, int acode, int num, char line, int year)
+ PhoneNumber ( int num, char line = 'B' )
+ PhoneNumber (int acode, int num, char line = 'C')
+ void setCountry(int ccode)
+ void setArea(int acode)
+void setNumber(int num)
+ void setType(char line)
+ void setYear(int yr)
+ int getCountry() const
+ int getArea() const
+ int getNumber() const
+ int getType() const
+ int getYear() const
+ bool doubleDigits() const //returns true if there is are double digits in the 7 digit number
+ void printNumber(ostream& out) const // area code and phone number only
+ void printPhoneNumberStats(ostream& out) const // prints all phone information |
The PhoneNumber constructor is overloaded, so that an application, which is creating a new PhoneNumber object, can do so without all info initially available.
Any constructor which does is not provided with all data must use default values for the missing data. Defaults to be used:
countryCode => 43
areaCode => 800
number => 8675309
type => 'H'
when => 1981
The set and get functions either set or return the value of the indicated member variable. The print functions output the indicated information to the ostream object 'out'. The print functions output the indicated information to the console.
COMMENTING A CLASS:
Classes should always contain these key comments:
- an introductory comment indicating what the class represents
- a comment for each member variable, indicating the role that variable plays in the class
- a comment prior to each function, stating what the function does, what it returns ( if anything )
Be sure your all code is well commented. The application should contain comments which indicate where the different tasks are taking place.
Here is the main program you must use:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
int main()
{
PhoneNumber firstNum;
PhoneNumber secondNum(39, 415, 8675555, 'B', 2012);
PhoneNumber thirdNum(1234567);
PhoneNumber fourthNum(1234566, 'C');
PhoneNumber fifthNum(925, 4392181);
PhoneNumber sixthNum(925, 5512346, 'H');
firstNum.printNumber(cout);
firstNum.printPhoneNumberStats(cout);
secondNum.printNumber(cout);
secondNum.printPhoneNumberStats(cout);
thirdNum.printNumber(cout);
thirdNum.printPhoneNumberStats(cout);
fourthNum.printNumber(cout);
fourthNum.printPhoneNumberStats(cout);
fifthNum.printNumber(cout);
fifthNum.printPhoneNumberStats(cout);
sixthNum.printNumber(cout);
sixthNum.printPhoneNumberStats(cout);
return 0;
}
|