Answered step by step
Verified Expert Solution
Question
1 Approved Answer
it should in C++ Write comments also in it Write both parts Problem-1: Ship, Cruise ship, Cargoship and Tankership is Design an abstract Ship dass
it should in C++
Write comments also in it
Write both parts
Problem-1: Ship, Cruise ship, Cargoship and Tankership is Design an abstract Ship dass that has the following members A member variable for the name of the ship astrine) A member variable for the year that the ship was built (string) A default constructor and appropriate accessors and mutators A virtual print function that displays the ship's name and the year it was built the ship) which must be implemented by all the classes. A virtual currentOnboardPayload function (which shows how many passengers, Carros Design a Cruiseship class that is derived from the Ship class. The Cruise Ship class should have the following members: A member variable for the maximum number of passenger's capacity (an int) A member variable to store current passengers on board on ship (an int) A default constructor and appropriate accessors and mutators A print function that overrides the print function in the base class. The Cruise Ship class's print function should display only the ship's name and the maximum number of passengers Design a CargoShip class that is derived from the Ship class. The CargoShip class should have the following members: A member variable for the cargo capacity in tonnage (an int). A member variable to store current cargo loaded on ship in tonnage (an int) A default constructor and appropriate accessors and mutators. A print function that overrides the print function in the base class The CargoShip class's print function should display only the ship's name and the ship's cargo capacity Design a TankerShip class that is derived from the Ship class. The TankerShip class should have the following members: A member variable for the oil capacity in barrels (an int). A member variable to store current oil loaded on ship in barrels (an int). A default constructor and appropriate accessors and mutators. A print function that overrides the print function in the base class. The TankerShip class's print function should display only the ship's name and the ship's cargo capacity Demonstrate the classes in a program that has an array or vector of Ship pointers. The array elements should be initialized with the addresses of dynamically allocated Ship, Cruise Ship CargoShip and TankerShipobjects. The program should then step through the array or vector, calling each object's print function and currentShipCapacity function with appropriate units. Problem-2: Implement following scenario and then test it by creating the object of Book and calling different functions on it in main function. -- No default values for the variables char of 's' or 'f' Author -name:String -email:String -Cender:char. +Author(name:String, enail:String, gender:char) *gethane():String .getEmail():String +set Enail(enail:String):void *eetGender().char toString():String -name:String -author:Author -price:double -tyrint -Book (name:String, author:Author, price:double) +Book (name:String, author:Ruthor, price:double,aty:int) getlane():String getAuthor(): Author getPrice():double setPriceprice: double):void *Betty:int setQty(aty:int):void toString():Strips Author[name=?, email?, gender-?]" print price "Book [name?, Author name, email, genders You need to reuse Author's tostring) Problem-1: Ship, Cruise ship, Cargoship and Tankership is Design an abstract Ship dass that has the following members A member variable for the name of the ship astrine) A member variable for the year that the ship was built (string) A default constructor and appropriate accessors and mutators A virtual print function that displays the ship's name and the year it was built the ship) which must be implemented by all the classes. A virtual currentOnboardPayload function (which shows how many passengers, Carros Design a Cruiseship class that is derived from the Ship class. The Cruise Ship class should have the following members: A member variable for the maximum number of passenger's capacity (an int) A member variable to store current passengers on board on ship (an int) A default constructor and appropriate accessors and mutators A print function that overrides the print function in the base class. The Cruise Ship class's print function should display only the ship's name and the maximum number of passengers Design a CargoShip class that is derived from the Ship class. The CargoShip class should have the following members: A member variable for the cargo capacity in tonnage (an int). A member variable to store current cargo loaded on ship in tonnage (an int) A default constructor and appropriate accessors and mutators. A print function that overrides the print function in the base class The CargoShip class's print function should display only the ship's name and the ship's cargo capacity Design a TankerShip class that is derived from the Ship class. The TankerShip class should have the following members: A member variable for the oil capacity in barrels (an int). A member variable to store current oil loaded on ship in barrels (an int). A default constructor and appropriate accessors and mutators. A print function that overrides the print function in the base class. The TankerShip class's print function should display only the ship's name and the ship's cargo capacity Demonstrate the classes in a program that has an array or vector of Ship pointers. The array elements should be initialized with the addresses of dynamically allocated Ship, Cruise Ship CargoShip and TankerShipobjects. The program should then step through the array or vector, calling each object's print function and currentShipCapacity function with appropriate units. Problem-2: Implement following scenario and then test it by creating the object of Book and calling different functions on it in main function. -- No default values for the variables char of 's' or 'f' Author -name:String -email:String -Cender:char. +Author(name:String, enail:String, gender:char) *gethane():String .getEmail():String +set Enail(enail:String):void *eetGender().char toString():String -name:String -author:Author -price:double -tyrint -Book (name:String, author:Author, price:double) +Book (name:String, author:Ruthor, price:double,aty:int) getlane():String getAuthor(): Author getPrice():double setPriceprice: double):void *Betty:int setQty(aty:int):void toString():Strips Author[name=?, email?, gender-?]" print price "Book [name?, Author name, email, genders You need to reuse Author's tostring)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started