Ship. CruiseShip, and CargoShip Classes
Design a Ship class that has the following members:
• A member variable for the name of the ship (a string)
• A member variable for the year that the ship was built (a string)
• A constructor and appropriate accessors and mutators
• A virtual print function that displays the ship’s name and the year it was built. Design a CruiseShip class that is derived from the Ship class. The CruiseShip class should have the following members:
• A member variable for the maximum number of passengers (an int)
• A constructor and appropriate accessors and mutators
• A print function that overrides the print function in the base class. The CruiseShip 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 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.
Demonstrate the classes in a
Want to see the full answer?
Check out a sample textbook solutionChapter 15 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Additional Engineering Textbook Solutions
Concepts Of Programming Languages
Software Engineering (10th Edition)
Java How To Program (Early Objects)
Starting Out With Visual Basic (8th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
- Assume that you have created a class named MyClass. The header of the MyClass constructor can be ____________. public MyClass() public MyClass (double d) Either of these can be the constructor header. Neither of these can be the constructor header.arrow_forwardExercise 1-Account class • Design a class named Account that contains : • A private int data field named id for the account • A private double data field named balance for the account • A privet Date data field named dateCreated that stores the date when the account was created • A no-arg constructor that creates a default account • A constructor that creates an account with the specified id and initial balance • The getters (i.e., accessors) and setters (i.e., mutators) methods for id and balance • The getter method for dateCreated • A method named withdraw that withdraws a specified amount from the account • A method named deposit that deposits a specified amount to the accountarrow_forwardINVENTORY CLASS You need to create an Inventory class containing the private data fields, as well as the methods for the Inventory class (object). Be sure your Inventory class defines the private data fields, at least one constructor, accessor and mutator methods, method overloading (to handle the data coming into the Inventory class as either a String and/or int/float), as well as all of the methods (methods to calculate) to manipulate the Inventory class (object). The data fields in the Inventory class include the inventory product number (int), inventory product description (String), inventory product price (float), inventory quantity on hand (int), inventory quantity on order (int), and inventory quantity sold (int). The Inventory class (java file) should also contain all of the static data fields, as well as static methods to handle the logic in counting all of the objects processed (counter), as well as totals (accumulators) for the total product inventory and the total product…arrow_forward
- Account class • Design a class named Account that contains:• A private int data field named id for the account• A private double data field named balance for the account• A private Date data field named dateCreated that stores the datewhen the account was created• A no-arg constructor that creates a default account• A constructor that creates an account with the specified id andinitial balance• The getters (i.e., accessors) and setters (i.e., mutators) methods forid and balance• The getter method for dateCreated• A method named withdraw that withdraws a specified amount fromthe account• A method named deposit that deposits a specified amount to the account TestAccount class• Write a test program named TestAccount that performsthe following:• Create an Account object with an account ID of 1122 and abalance of 20,000 S.R.• Use the withdraw method to withdraw 2,500 S.R.• Use the deposit method to deposit 3,000 S.R.• Print the balance and the date when this account was createdarrow_forwardProblem: Course information System Super Class Attributes Methods : Student Studentid, StudentName, Address, Level Set the student details using constructor Display the Student details Sub class : Course Attributes Methods Coures1, Course2, Credit1, Credit 2, Mark1, Mark2 Set the course details using constructor Calculate the total number of credits Calculate the total number of marks Display the course details Driver Class : Display the student details and course details. The following information are required for the assignment Properties with proper data types Methods with proper return types and scope Demonstration of OOP feature- (Inheritance) Demonstration of user defined package Proper naming convention Proper comments in each program and within program Purpose of each code should be explained. Program Execution (output) Presentation (Word Document) 56S1740arrow_forwardC++ programming Create a class called "MyClass" Create an object called "myObj" in main and access the attributes Create multiple objects of one class Define a function inside the class, and we name it "myMethodin". Define a function outside the class, and we name it "myMethodout".arrow_forward
- protected class members are only accessible inside the class (true/false) it’s possible to set the value of a private member variable of a class (true/false) setter and getter functions should be private (true/false)arrow_forwardc++ ooparrow_forwardWhat is true about static data member? (i) It must be defined inside the class (ii) It must be defined outside the class (iii) It must be defined in main function (iv) It must be defined using constructorarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT