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 4 digits.
In addition, the class should have the following constructors and member
functions
Constructor : will month to 1, day to 1 and year to 2024
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 1 to 12. If
invalid, set month to 1. Also, values for the day should be validated according
to the month. For example, if month is 2 then day should range from 1 to 28.
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 mm/dd/yy 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 d1 using the default constructor. Nothing is
supplied.
creating a Date object called d2 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()
Student(int, String,Date,double)
Student(int,String,int,int,int,double)
+ setId(int id) : void
+ setName(String n) : void
+ setDoB(Date d) : void
+ setHeight(double 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 d1, d2, d3 with values of your own
choosing.
create three different Student objects s1,s2 and s3 using d1,d2 and d3
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 3.
Assign s1, s2 and s3 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 3.
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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!