Question: Write a class called Date that has the following member variables: month : an int data to hold month day : an int data to
Write a class called Date that has the following member variables:
month : an int data to hold month
day : an int data to hold day
year : an int data to hold year and it will be digits.
In addition, the class should have the following constructors and member
functions
Constructor : will month to day to and year to
Constructor : an overload of the Constructor above but this time, the
values for month, day and year will be provided. In addition, value for the
month should be validated such that it will have only values from to If
invalid, set month to Also, values for the day should be validated according
to the month. For example, if month is then day should range from to
You can ignore leap years for now.
Accessors Getters : appropriate accessor methods for each of
the data members. These methods should be const methods.
Mutators Setters : appropriate mutator methods for each of the
data members.
print : method to print the date in the format mmddyy with yy as
four digits.
You must define the specification in a file called Date.h and the implementation
of constructors and the methods should be another file called Date.cpp
Demonstrate that your class is working by doing the following:
creating a Date object called d using the default constructor. Nothing is
supplied.
creating a Date object called d by providing values for month, day and
year.
Call the print method in each object to show that it is working correctly.
Continue to next requirement.
Write a class called Student using the UML shown below:
Student
id : int
name : String
dateOfBirth : Date
height : double
Student
Studentint String,Date,double
StudentintString,int,int,int,double
setIdint id : void
setNameString n : void
setDoBDate d : void
setHeightdouble h : void
getId const : int
getName const : String
getDate const : Date
getHeight const : double
print const : void
Write the specification of the class Student in a file called student.h
Write the implementation of the class Student in a file called student.cpp
Constructor : set values to any value you like and there are three
constructors
Accessor Getter : to get value for id name and height. The date
field already has getters in the Date class and can be called when needed.
Mutator Setter : to set value of id name and height. Mutators for
the Date class can be called when needed.
print : method to data members of the Student class. The print
method of the Date class should be used to print birth date rather than
define again.
Demonstrate that your class is working by doing the following:
create three different Date objects d d d with values of your own
choosing.
create three different Student objects ss and s using dd and d
and values for the other data members of the Student class. Use values of
your own choosing.
Create an array called stuArray of type Student of size
Assign s s and s to the this stuArray array.
Use a loop to repeat three times to print each element of the array
stuArray by calling the print method of Student from this loop.
Now, create a different array called stuPtrArray of type Student
pointers of size
In a loop that will loop three times, dynamically create three different
objects of type student by asking user to enter each value and then create a
Student object dynamically and assign it to each element of the array.
Hence, the values for the student id name, date of birth and height should
be keyed from the keyboard. You may use any constructor that you feel
comfortable using.
In another loop, access each element of the stuPtrArray and call the
print method of Student to print information about each student.
What to submit?
The following files : Ddte.h date.cpp student.h student.cpp
And your test program which is another cpp file
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
