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 19:20
Terri needs to insert a cover page into her document. where should she go to access the commands to do so? o insert tab, objects group o insert tab, illustrations group o insert tab, pages group o insert tab, media group submit
Answers: 1
question
Computers and Technology, 23.06.2019 03:00
Jason, samantha, ravi, sheila, and ankit are preparing for an upcoming marathon. each day of the week, they run a certain number of miles and write them into a notebook. at the end of the week, they would like to know the number of miles run each day, the total miles for the week, and average miles run each day. write a program to them analyze their data. your program must contain parallel arrays: an array to store the names of the runners and a two-dimensional array of five rows and seven columns to store the number of miles run by each runner each day. furthermore, your program must contain at least the following functions: a function to read and store the runners’ names and the numbers of miles run each day; a function to find the total miles run by each runner and the average number of miles run each day; and a function to output the results. (you may assume that the input data is stored in a file and each line of data is in the following form: runnername milesday1 milesday2 milesday3 milesday4 milesday5 milesday6 milesday7.)
Answers: 3
question
Computers and Technology, 23.06.2019 12:00
What type of slide show is a dynamic and eye-catching way to familiarize potential customers with what your company has to offer? a. ole b. photo album c. brochure d. office clipboard
Answers: 2
question
Computers and Technology, 23.06.2019 16:30
You have read about the beginnings of the internet and how it was created. what was the internet originally created to do? (select all that apply) share research. play games. communicate. share documents. sell toys
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, 26.09.2019 03:50
question
Mathematics, 26.09.2019 03:50
Questions on the website: 13722360