subject

Hello I am having touble with finishing the code of Designing a class Named Month Design a class named Month. The class should have the following private members: - name A string object that holds the name of a month, such as “January,” “February,” etc. - monthNumber An integer variable that holds the number of the month. For example, January would be 1, February would be 2, etc. Valid values for this variable are 1 through 12. In addition, provide the following member functions: - A default constructor that sets monthNumber to 1 and name to “January.” - A constructor that accepts the name of the month as an argument. It should set name to the value passed as the argument and set monthNumber to the correct value. - A constructor that accepts the number of the month as an argument. It should set monthNumber to the value passed as the argument and set name to the correct month name. - Appropriate set and get functions for the name and monthNumber member variables. - Prefix and postfix overloaded ++ operator functions that increment monthNumber and set name to the name of next month.
I also need to have pre fix ++ and pro fix-- functions need to be doing different things and i need to adding the result of pre and post to another variable to see the true effect of pre and post fix.
This is my code so far please help

#include // header the contains function for input/output
#include > (istream&, Month&);
};
//
//Implementation section of the function created
//
Month ::Month() //default constructor to set the name of the month to January and 1
{
name = "January";
monthNumber = 1;
}

Month::Month(string name) //1 parameter constructor that retrieves the name of the month
{
for (int count = 0; count < 12; count++)
{
if (name == monthNames[count])//if the name of the month and monthname are the same
{
monthNumber = count + 1;//month number will be counter +1 because it is at 0
break;
}
if (count == 11)
{
cout << " Invalid month name.\n" << endl;
}
}
}
Month::Month(int n)//constructor with number of month it is in parameter
{
if (n < 1 || n > 12)
{
cout << "Invalid month number. Please Enter month number 1 through 12" << endl;

}
else
{
monthNumber = n;
name = monthNames[n - 1]; // size of number start from 0 so size-1 will give correct
}
}
//
//Setter Functions(mutator functions) to manipulate the
//data
//
void Month::setName(string nm)
{
for (int count = 0; count < 12; count++)
{
if (nm == monthNames[count])
{
//I would assign the name to monthname because it is a match
nm = monthNames[count];

}
else
{
cout << "Not valid Month Name";
}
}
return;

}
//
//Mutator Function for Month Number to change data
//
void Month::setMonthNumber(int nb)
{
//checking validation of correct input to go throug
if (nb < 1 || nb>12)
cout << "Invalid month number. Please Enter month number 1 through 12";
else
{
monthNumber = nb; //valid so monthnumber input will be assigned to monthNumber variable to be changed
name = monthNames[nb - 1];// valid so monthname in the array will be assiigned mutated to change in name
}//if closed

}//function closed

//
Getter functions to get the data Accessors should always declare const
so it doesnt change the calling obj by accident
//
int Month::getmonthNumber() const //getter function to return number
{
return monthNumber;
}
string Month::getName()const // getter function to return name
{
return name;
}
//
// prefix -- operator check if months are correct and because its an array
// and it starts from 0 as january we make sure once it goes over 11 to 12
// it will go back to month equalling january as 1
Month::operator++()
{
}
int Month::operator--()
{
return;
}

/* void setName(string name)
for ()
{
if (name == = )
{
cout << " error";
}

void setMonthNumner(int num)
{}
prefixt opeator
post fix opeator
void print()
// cin print >> opeater
ifstream <<
void print()
ofstream <<
// cout << opeater
{} */

int main()
{
int mNumber;
string mname;
cout << "Enter Month number between 1-12";
cin >> mNumber;
while(mNumber<12 && mNumber>0)
Month m1; //instantiation M1 is instance of Month Obj
Month m2(int); //m2 is a instance of Month object
Month m3(string); //m3 is a instance of Month object

//create objects for month class
//set and get the month name
//set and get the month number
//out << "Type in a Month :";

system("pause");
return 0;

}

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:00, crimhill
When is it appropriate to use an absolute reference
Answers: 1
image
Computers and Technology, 22.06.2019 18:30, Jessieeeeey
Kto rozmawia z clamentain przez krótkofalówke w the walking dead która śledzi lee w 4 epizodzie
Answers: 1
image
Computers and Technology, 22.06.2019 21:00, raquelle66
So im doing this school challenge and the teachers said whats the average text a student gets a day so i need to get about 20 in a day but dont know how can you guys 2163371293
Answers: 2
image
Computers and Technology, 23.06.2019 22:30, keel5468
You draw two cards from a standard deck of 52 cards, but before you draw the second card, you put the first one back and reshuffle the deck. (a) are the outcomes on the two cards independent? why?
Answers: 3
You know the right answer?
Hello I am having touble with finishing the code of Designing a class Named Month Design a class na...

Questions in other subjects:

Konu
SAT, 30.10.2020 22:40
Konu
Arts, 30.10.2020 22:40
Konu
Mathematics, 30.10.2020 22:40
Konu
Mathematics, 30.10.2020 22:40
Konu
Mathematics, 30.10.2020 22:40
Konu
Business, 30.10.2020 22:40