Question: Problem Statement: You are asked to represent the real-world entity Car in an object oriented program. For the purpose of this exercise, only assume that

Problem Statement:

You are asked to represent the real-world entity Car in an object oriented program. For the purpose of this exercise, only assume that an object of type Car has a make and can be created out of three different parts, engine, wheel, and window. To represent these components you need to create a separate class to represent each one. The specifications for each of the required classes are given below:

Class Engine: This class should describe an engine in terms of its Cylinder Capacity (CC), number of cylinders, number of valves, and horse power. The class needs to define two constructors, a default one that accepts no arguments but initializes class members to reasonable values while the second one, a copy constructor, that accepts value for the four attributes and assign them to the class data members. The class should also define four methods, start(), stop(),getHorsePower(), and setHorsePower(). The start() and stop() methods will just display, on the screen, appropriate messages when called. The setHorsePower() will receive an integer value for the horse power and assign it to the appropriate data member while the getHorsePower() will receive no argument but will return the current value of the horse power.

Class Wheel: This class should describe the wheels in a Car in terms of how many wheels a car has, the size of the wheel, and proper inflation pressure. The class needs to define a non-default constructor that accepts values for the three attributes and assign them to corresponding class data members. The class should also define two methods, getPressure() and setPressure(). The setPressure() will receive an integer value for the proper psi value and assign it to appropriate data member while the getPressure() will receive no argument but will return the current value of the tire pressure.

Class Window: This class should describe the Windows in a car in terms of how many windows a car has and the width and the height of a window (assuming all windows have the same dimension) The class needs to define a non-default constructor that accepts values for the three attributes and assign them to corresponding class data members. The class should also define three methods, rollUp(), rollDown(), and ComputerWindowArea(). Both the rollUp() and rollDown() method will just display appropriate messages on the screen when called. The ComputerWindowArea() will compute the area of a window (assuming it is a rectangle) and returning the area value to the caller.

Class Vehicle: This should be an abstract class that is the parent class of class Car, described below. Class Vehicle should represent any moving object used for transportation. This class, Vehicle, should define a constructor the will accept an engine, a wheel, and a window objects. This class should also define two abstract methods called displayWheelPressure() and displayWindowArea(). In addition, it will define a regular method called displayValveNumber() that will print a message on the screen indicating how many valves are in this vehicle.

Class Car: This class should represent a car, a real-word entity. Each car is a vehicle that must have an engine, a wheel, and a window objects in addition to a string data filed that represents the make of this car. To construct an object of type Car, you need to invoke a constructor that accepts objects of types Engine, Wheel, and Window in addition to a string, make. The class should also override its parents methods displayWheelPressure() and displayWindowArea() as well as providing its own version of displayValveNumber(). The task of each of these methods is to display, on the screen, the value described by the method name.

Class TestCar: This is a driver class which will have the main() method. The class will create two objects of type Car but store them into objects of type Vehicle. The first car has an Engine with the following specifications (CC = 2400, Cylinder # = 4, # of valves = 16, and hp = 180). This car object should have 4 wheels, of size 265, and proper pressure of 33. Also it has 2 windows, each is 45X50 in size and its make is Mercedes-Benz. For the second Car object, your program should assign appropriate value for the engine specifications. This second car object should have 4 wheels, of size 225, and proper pressure of 35. Also it has a 4 windows, each is 50X60 in size and its make Honda. After creating the two objects the program should display (using appropriate messages) for every object: the car make, the wheel pressure, the area of the window, the number of valves, and the horse power of the engine of that object.

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 Databases Questions!