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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 09:00
Which best describes the condition under which the unicode output is the same as plain text?
Answers: 3
question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. which step can possibly increase the severity of an incident? a. separating sensitive data from non-sensitive data b. immediately spreading the news about the incident response plan c. installing new hard disks d. increasing access controls
Answers: 2
question
Computers and Technology, 23.06.2019 23:30
Worth 50 points answer them bc i am not sure if i am wrong
Answers: 1
question
Computers and Technology, 24.06.2019 09:30
What is the definition of digital literacy?
Answers: 1
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
question
Mathematics, 12.08.2020 21:01
question
Chemistry, 12.08.2020 21:01
Questions on the website: 13722361