CSCI 270-01-Assignement – 2: Abstract Base Class and MultipleInheritance
(70 points)
Due October 31, at 11:55 pm
Part 1: Multiple Inheritance (40pts)
Exercise 1 – Class Date (14pts)
1. (4pts)Create a class named Date with the following protected attributes:
int day;
int month;
int year;
2. (4pts)Implement the constructors with and without parameters of the class Date.
3. (6pts)Implement the getters and setters of the class Date.
Exercise 2 – Class Time (14pts)
1. (4pts)Create a class named Time with the following protected attributes:
int hou;
int min;
int sec;
2. (4pts)Implement the constructors with and without parameters of the class Time.
3. (6pts)Implement the getters and setters of the class Time.
Exercise 3 – Class DateTime (12pts)
1. (2pts)Create a class named DateTime that inherits from the classes Date and Time. The
access specifier for the classes Time and Date is public.
2. (4pts)Implement the constructors with and without parameters of the class DateTime.
3. (2pts)Implement the function showDateTime that displays the date and time.
4. (4 pts)Test your code by creating two objects of type DateTime; the first object using the
constructor without parameters and the second object using the constructor with
parameters.
Display the date and time of the two objects by calling the function showDateTime.
Example of the output of the function showDateTime for the two objects
1/1/1900 0:0:0
02/25/2009 6:20:55
1
Part 2: Abstract Base Class and Pure Virtual Functions (30pts)
Exercise 1
1. (3pts)Create an abstract base class named: Shape. The class Shape contains a public pure
virtual function named display();
2. (3pts)Create another class named: Rectangle. The class Rectangle contains the following
private properties:
double width;
double length;
3. (4pts)Implement the constructor with and without parameters of the class Rectangle.
4. (4pts)Implement the getters and setters of the class Rectangle.
5. (2pts)Override the function display of the class base Shape to display the length and width of
the Rectangle.
6. (2pts)Create another class named: Cube. The class Cube contains the following private
property:
double height;
7. (4pts)Implement the constructor with and without parameters of the class Cube.
8. (2pts)Implement the getters and setters of the class Cube.
9. (2pts)Override the function display of the class Rectangle to display the length, width and the
height of the Cube. Do not forget to call the function display of the class Rectangle.
10. (4pts)Test your code by creating two objects:
A Rectangle r1 of width = 5 and length = 9;
A Cube c1 of width = 4, length = 7, and height = 10;
Display the dimensions of the rectangle r1 using the function display.
Display the dimensions of the cube c1 using the function display.
2
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more