Need help getting started on a classes assignment?

I need help getting started on this assignment: http://hypergrade.com/grader/problem_set.php?id=1075

Here is my current code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

class PhoneNumber{
	private:
	int countryCode; //2 digit country code
	int areaCode; //3 digit area code
	int number; //7 digit phone number
	char type; //'H', 'C', or 'B' for home, cell, or business
	int year; //year the entry was made
	
	public:
	void setCountry();
	void setArea();
	void setType();
	void setYear();
	int getCountry() const;
	int getArea() const;
	int getNumber() const;
	int getType() const;
	int getYear() const;
	bool doubleDigits() const; //returns true if there are double digits in the 7 digit #
	void printNumber(ostream& out) const; //area code and phone number only
	void printNumberStats(ostream& out) const; //prints all phone info
};

void PhoneNumber::setCountry(int ccode){
	countryCode=ccode;
}

void PhoneNumber::setArea(int acode){
	areaCode=acode;
}

void PhoneNumber::setType(char line){
	type=line;
}

void PhoneNumber::setYear(int yr){
	year=yr;
}







//main function
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;
}


What is good about the code? Whats bad?
Any help is greatly appreciated.
Why did you include header #include <fstream>? Where is it used?

You defined data member type as char ( char type; ) howerver getter ( int getType() const; ) returns int.

In the class you declare function setCountry without parameters ( void setCountry(); ) but define it
with a parameter (void PhoneNumber::setCountry(int ccode) ).

Your class has only the default constructor but you called constructors with parameters:

PhoneNumber secondNum(39, 415, 8675555, 'B', 2012);
PhoneNumber thirdNum(1234567);
PhoneNumber fourthNum(1234566, 'C');
PhoneNumber fifthNum(925, 4392181);
PhoneNumber sixthNum(925, 5512346, 'H');
The main program (i.e. int main()) MUST be used according to the assignment.

main:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
}
 


Topic archived. No new replies allowed.