Question For each class create an *.h and *.cpp file that

Question : Question For each class create an *.h and *.cpp file that : 870692


For each class create an *.h and *.cpp file that contains the class definition and the member functions. There will also be one file called 'main.cpp' that contains the main() function, and will instantiate the objects and test them.

Create 2 new classes for this project, one will be a 'Song' class and one will be a 'Date' class

Take the song class. Add the project new files called Song.h and Song.cpp   and create the new class from scratch in those files. Use the 3 most important data members that describe the class/object to build (Example if I had book I would want Ttile Author and Pages so choose 3 for a song) and the write 2 constructors, 3 get member functions, 3 set member functions and a toString method and that is all.

Once you have created a new class, you need to adjust the main() function to allow the user to input the data members for your class and create an object of that type. Use the toString method to then display the new object on the screen. When the project is complete, both classes/objects should be created and displayed with main().

Please do not use the same 3 data types for any class's member variables. That is, do not make them all ' int ' or all ' string '.

Date class, the data members will be int day; int year; string month;Create a Date class with 2 constructors, 3 get member functions, 3 set member functions and a toString method. Adjust the main() function to use the Date class.

When the user wants to build a Date object, on the screen input 3 values, one for each member variable. Insert values into the Date object then output a simple message like:

"The Date object is: March 2, 2013"

It is very important that the data input be inserted INTO the object, and pulled back OUT of the object to print the above message.

Write a method: int getMonthNumber(); that returns the proper value 1-12 based on the string stored in the month variable. It should return the value -1 if the current value in the month variable is NOT valid. DO NOT store the month number in a member variable (local is OK), generate it when the method is called.

Write a method: void printDate( int format ); when it is called the format value will determine how the date is output to the screen using cout:

format 0: Mar 12, 2013

format 1: 12 Mar 2013

format 2: 3-12-2013

format 3: 3/12/13

Of course the actual values stored in the object will be output, this is only an example. Modify the main program to print the date in these additional formats. Optional: Use the int getMonthNumber(); method to check if the user enters a proper value for the month variable.

_____ Three global variables (not the same type)

_____ Two constructor methods

_____ Three 'get' methods

_____ Three 'set' methods

_____ One 'toString' method

_____ In the main function you create an object, insert values into the object, and print the object

            _____ Five total classes Song.cpp, Song.h, Date.cpp, Date.h and a main()


5 (1 Ratings )

Computer Science 1 Week Ago 8 Views
This Question has Been Answered!

Related Answers
Unlimited Access Free
Explore More than 2 Million+
  • Textbook Solutions
  • Flashcards
  • Homework Answers
  • Documents
Signup for Instant Access!
Ask an Expert
Our Experts can answer your tough homework and study questions
154220 Computer Science Questions Answered!
Post a Question