Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 3 (20 MARKS) This question demonstrates the use of inheritance and polymorphism. Design a Ship class that has the following members: A field for

image text in transcribed
image text in transcribed
QUESTION 3 (20 MARKS) This question demonstrates the use of inheritance and polymorphism. Design a Ship class that has the following members: A field for the name of the ship (a string). A field for the year that the ship was built (a string). A constructor and appropriate accessors and mutators. AtoString method that overrides the toString method in the Object class. The Ship class toString method should display the ship's name and the year it was built. Design a Cruise Ship class that extends the Ship class. The Cruise Ship class should have the following members: A field for the maximum number of passengers (an int). A constructor and appropriate accessors and mutators. A toString method that overrides the toString method in the base class. The Cruise Ship class's toString method should display only the ship's name and the maximum number of passengers. Design a CargoShip class that extends the Ship class. The CargoShip class should have the following members: A field for the cargo capacity in tonnage (an int). A constructor and appropriate accessors and mutators. A toString method that overrides the toString method in the base class. The CargoShip class's toString method should display only the ship's name and the ship's cargo capacity. Demonstrate the classes in a program that has a Ship array. Assign various Ship, Cruise Ship, and CargoShip objects to the array elements. The program should then step through the array and print each object. Assignment Marking Scheme 1/3 marks - Proper documentation and readability of the program - Header documentation includes: Course Name, Student name, Student number, Assignment number and date completed. - There must be a general description of the purpose of the method/function used. - Appropriate comments: where necessary, within the method function, there should be inline comment descriptions of declaration of variables, statements, control structures and etc. to improve the readability of the program. - Properly named variables: well-chosen descriptive variable names make it easier for readers or analysts to understand what the intent of the variable or what the system is doing. Example: payRate =5.0 as oppose to x=5. Properly named variable can also avoid naming collision. - Properly named method/function: method name should imply the intent of the method and what the method is doing. - All identifier names should follow standard naming convention in Java. - Proper indentation and spacing in program improves readability. 1/3 marks - Programming language knowledge and skills - Demonstrate the use of concepts in Java such as: object-orientation, interface, package, class, exception and etc., learnt in the class. - Demonstrate the use of basic programming concepts. - Use of features not presented in the class must be relevant and properly commented. - Program shows a clear understanding of programming concepts in general. - Good programming practices and skills 1/3 marks - Program compile and run with correct output

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions