Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Chapter 10. PC #10. Ship, CruiseShip, and CargoShip Classes (read instructions carefully) Design a Ship class that the following members: A field for the name

Chapter 10. PC #10. Ship, CruiseShip, and CargoShip Classes (read instructions carefully) Design a Ship class that 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. A toString method that displays the ships name and the year it was built. Design a CruiseShip class that extends the Ship class. The CruiseShip 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 CruiseShip classs toString method should display only the ships 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 classs toString method should display only the ships name and the ships cargo capacity. In the main class, you should read the input file and create an array containing Ship, CargoShip, CruiseShip objects based on the information provided on each line. The file is in CSV (comma separated values) format. This means each line contains multiple data elements separated by comma. You can use Scanner class to input the data or if you know how to work with StringTokenizer you can also use it. Another option is to use the split() method in the String class. The first column in the file contains the ship type (Ship, CruiseShip, or CargoShip) as a String. The second column contains the Ship Name as a String. The third column contains Year Built as a String. The forth column contains different information for different ship types: For ship type = Ship - empty (ignore) For ship type=CargoShip - Cargo Capacity (int) For ship type=CruiseShip - Max Passengers (int)

In java language.

Ouput

Cruise Ship Ship Name: Aegean Spirit Year Built: 2003 Max Passengers: 4,500 Standard Ship Ship Name: Classica Year Built: 1990 Cargo Ship Ship Name: Edith Maersk Year Built: 2007 Cargo Capacity: 170,794 Cargo Ship Ship Name: Emma Maersk Year Built: 2006 Cargo Capacity: 156,907 Cruise Ship Ship Name: Enchanted Capri Year Built: 1970 Max Passengers: 7,000 Cargo Ship Ship Name: Estelle Maersk Year Built: 2006 Cargo Capacity: 151,687 Cruise Ship Ship Name: Explorer of the Seas Year Built: 2001 Max Passengers: 9,500 Standard Ship Ship Name: MV Delight Year Built: 1985 Cargo Ship Ship Name: Ocean Glory Year Built: 2006 Cargo Capacity: 161,788 Cruise Ship Ship Name: Our Lady Year Built: 1960 Max Passengers: 3,500 Standard Ship Ship Name: Provence Year Built: 1995 Standard Ship Ship Name: SS Desabla Year Built: 1913 Cruise Ship Ship Name: Symphony Year Built: 2001 Max Passengers: 10,000 

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

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago