Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Define a class called Month that is an abstract data type for a month. Your clas

ID: 440306 • Letter: D

Question

Define a class called Month that is an abstract data type for a month. Your class will have one member variable of type int to represent a month (1 for January, 2 for February, and so forth). The complete class will include all the following member functions: a constructor to set the month using the first three letters in the name of the month as three arguments, a constructor to set the month using an integer argument (1 for January, 2 for February, and so forth), a default constructor, an input function that reads the month as an integer, an input function that reads the month as the first three letters in the name of the month, an output function that outputs the month as an integer, an output function that outputs the first three letters in the name of the month, and a member function that returns the next month as a value of type Month. For this problem write part of the class - the three constructors and the two output functions. Embed the class definition in a test program.

Explanation / Answer

The "test program" is basically a driver. Your class itself won't do anything if you just run it on its own, so you create a program that actually uses the Month class to see if it behaves how you would expect.

What you should do is write a program that creates a Month object using all of the different constructors, and then uses those created objects to test all of the other functions you wrote. So maybe your main would contain something like this:

#Include "month.h"

int main () {

Month month1;
Month month2('j','u','n');
Month month3(3);

//Test functions here

return 0;
}

So you include your Month header file (or .cpp file if you have no header file) and then your test program (aka main() ) can create Month objects and then manipulate them.

I wasn't sure if your input/output functions did their input/output through main() or interacted directly with the user, so I didn't include them.

Does that help?

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote