Month.cpp Class to a Main.cpp!! Help!
Sep 12, 2014 at 5:50pm UTC
Someone please help me get started with this program. i am pretty sure i have all the necessary Private and public constructors, getters, etc... i just need help with formula placement and so on.
this is the problem and what it wants you to do.
Complete Programming Challenge 7 at the end of the chapter titled More About Classes. Modifications:
Don't need to overload << or >>
Don't need to overload postifx ++ or postfix --
Name the file Month.cpp
See the driver (in solution) to find the appropriate method names
this is my class that i have built for the main.cpp
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
#include <iostream>
#include <string>
using namespace std;
class Month
{
private :
string name;
int num;
public :
Month();
Month(int n);
Month(string n);
string getMonthName();
int getMonthNumber();
void setMonth(int n);
void setMonth(string n);
Month& operator ++();
};
Month::Month()
{
}
Month::Month(int n)
{
}
Month::Month(string n)
{
}
string Month::getMonthName()
{
return //string; <= maybe i need to change this?
}
int Month::getMonthNumber()
{
return num; // i think this is fine
}
void Month::setMonth(int n)
{
}
void Month::setMonth(string n)
{
}
Month& operator ++()
{
}
this is the main.cpp, my class ^^ will be tested with this vv
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
#include <iostream>
#include "Month.cpp"
using namespace std;
void doOutput(string name, Month &m)
{
cout << name << ": " << m.getMonthName() << " (" << m.getMonthNumber() << ")" << endl;
}
int main()
{
cout << "Testing constructors" << endl;
Month m1;
Month m2(5);
Month m3("December" );
doOutput("m1" , m1);
doOutput("m2" , m2);
doOutput("m3" , m3);
cout << "Testing setMonth methods" << endl;
m1.setMonth(8);
m2.setMonth("February" );
m3.setMonth(3);
doOutput("m1" , m1);
doOutput("m2" , m2);
doOutput("m3" , m3);
cout << "Testing prefix ++" << endl;
for (int x = 0; x < 12; x++)
{
++m1;
doOutput("m1" , m1);
}
for (int x = 0; x < 12; x++)
{
++m2;
doOutput("m2" , m2);
}
for (int x = 0; x < 12; x++)
{
++m3;
doOutput("m3" , m3);
}
}
Last edited on Sep 15, 2014 at 7:53pm UTC
Topic archived. No new replies allowed.