Question: use c++ programming 9 Figure 9A shows a UML Class diagram with 3 classes : Traincarriage, PassengerCarriage and CargoCarriage, along with their attributes, constructor and

use c++ programming

use c++ programming 9 Figure 9A shows a UML Class diagram with

3 classes : Traincarriage, PassengerCarriage and CargoCarriage, along with their attributes, constructor

9 Figure 9A shows a UML Class diagram with 3 classes : Traincarriage, PassengerCarriage and CargoCarriage, along with their attributes, constructor and method signature. Note that method showData() has the exact same method signature for all 3 classes, hence, the super-class TrainCarriage's showData() is meant to be over-ridden by the other 2 sub-classes TrainCarriage #name #lengthInM : string : int Fig. 9-A +TrainCarriage name: string, lengthInM : string) +showData ) void CargoCarriage Passenger Carriage #seatingCapacity : int #isluxuryclass : bool #maxVolume InCubicMfloat #maxWeightInkg : float + PassengerCarriage name : string, lengthInM : int, seatingCapacity : int, 18 Luxuryclass bool + CargoCarriage name : string, lengthInM : int, maxVolumeInCubic : float, maxWeight Inkg : float +ShowData(); void +showData() void int main 1 Traincarriage + tArray [3]; tArray [O] - new CargoCarriage ("Cargo", 60, 1368.38, 8800.50); tArray (1) = new PassengerCarriage "Passenger", 50, 30, true); tArray [2] - new TrainCarriage ("Generic Carriage", 40); for (int i=0; ishowData); Fig. 9.B return (0) Figure 9-C provides a sample output when the program (in Fig 9-B) is run. Fig. 9-c Name : Cargo Length In Meters) : 60 Max Volume : 1368.38 cu M Max Weight : 8800.5 kg Name Passenger Length In Meters) : 50 Seating Capacity : 30 Is Luxury Class? : Yes Name : Generic Carriage Length (In Meters) : 40 Based on the information provided in all 3 figures, you are to demonstrate the Object Oriented principles of Encapsulation, Inheritance and Polymorphism by : a) Writing the class declarations for Traincarriage, Passengercarriage and Cargocarriage. Where applicable, you are to include all the necessary header guards (e.g. #Inde... #define ...) C++ library or user-defined headers and namespace ... as if you are writing them in separate TrainCarriage.h. PassengerCarriage.h and CargoCarriage.h files! (Note: you may write your answers on 1-2 pages if possible, there is no need to use a new page in your answer document for each class declaration) (6 marks) b) . Writing the class implementation code for Traincarriage, PassengerCarriage and CargoCarriage. Where applicable, you are to include all the necessary header guards (e.g. #ifndef ... #define ...) C++ library or user-defined headers and namespace ... as if you are writing them in separate TrainCarriage.cpp. Passenger Carriage.cpp and CargoCarriage.cpp files! (Note: you may write your answers on 1-2 pages if possible, there is no need to use a new page in your answer document for each class implementation) (6 marks)

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!