Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A Harbor has enough anchor space for 5 ships and one pier for loading/unloading. A Ship comes as either a Cruise Ship or a CargoShip.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

A Harbor has enough anchor space for 5 ships and one pier for loading/unloading. A Ship comes as either a Cruise Ship or a CargoShip. We will need to create classes for Ship, Cruise Ship, Cargoship, Harbor, and an Outer Main to simulate scenarios in a busy harbor. 1. Class Description 1.1. Ship 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 (an int) Constructors o for all fields provided for no built year provided (set the built year to -1) for no name provided (set name to ") o for neither provided . Appropriate getters and setters AtoString method that displays the ship's name and the year it was built. If the ship has no name or a negative year of build, "unknown" should be used instead. 1.2. CruiseShip Design a CruiseShip class that is derived from the Ship class. The Cruiseship class should have the following members: A field for the maximum number of passengers (an int) Constructors for all data provided o for only passengers provided o any other as needed Appropriate setters and getters AtoString method that overrides the according method in the superclass. It should additionally display the maximum number of passengers. 1.3. CargoShip Design a CargoShip class that is derived from the ship class. The Cargoship dass should have the following members: . - blackboard.cmich.edu zyBooks My library HD blackboard Cheggo Mail Outlook power 1.3. CargoShip Design a CargoShip class that is derived from the Ship class. The CargoShip class should have the following members: A field for the cargo capacity in tonnage (an int) Constructors o for all data provided o for only tonnage provided o any other as needed Appropriate setters and getters A toString method that overrides the according method in the superclass. It should additionally display the ship's cargo capacity 1.4. Harbor The Harbor class is holding five anchor spaces for ships and one pier for loading & unloading. The anchor spaces The pier Harbor The Harbor class is holding five anchor spaces for ships and one pier for loading & unloading. The anchor spaces The pier You could use an array of type Ship to serve as the fixed size anchor spaces. If you use ArrayList, note that it's not fix size and the operations (i.e., ArrayList methods) like "add" or "remove" will cause the size to grow or shrink. The pier should also be of type Ship The Harbor class implements the following interfaces (found them on Blackboard with the assignment): public interface Anchoring { J! Sails a ship into harbor. Note that the anchor spaces could be all occupied then the anchoring shou boolean anchor Shipintarbor(Ship ship); Shiats from anchor Soot. void sailShipfrowerbor(int anchor Spot); int shipsInarbor(); how any ships are there? public interface LoadingPierr public boolean pierIsBusy Whether or not a ship is using hid to their 1 Hote that if the pier is busy, no other ships can use it. nd before ship is moved into the pier, it should be anchored public boolean start Pier(int anchorsoot); Ship is done at the pler, put into an anchor spot Note that the ship must be anchored after they public boolean donePierO; the ter C Cheggo Mail -- Outlook The Harbor will also require a toString method that calls each ship's respective toString method (i.e. the Harbor's toString method lists all the ships currently anchored and the one that might be at the pier). 2. Scenario Simulation Implement scenario in OuterMain class and display corresponding output. Your scenario should involve the following jobs at possible situation: creating new ship(s) anchoring ships into harbor (anchor spots may be full adding ships into pier (pier may be occupied removing ship from pier (the ship may return to anchor spot or.. Sailing ship (move it out from the harbor pier etc. 3. Example Outputs 3.1. Scenario #1: Created new ship: Unknown, built in Unknown Shinc anchored. 1 public interface Anchoring { // Sails a ship into harbor. // Note that the anchor spaces could be all occupied then the anchoring should fail boolean anchorShipInHarbor(Ship ship); 11 Ship sails away from anchor spot. void sailShipFromHarbor (int anchorSpot); int ships InHarbor(); // How many ships are there? public interface LoadingPier { public boolean pierIsBusy 0; // whether or not a ship is using the pier. 1 Move a ship from anchor to the pier. Note that if the pier is busy, no other ships can use it. 11 and before a ship is moved into the pier, it should be anchored out from the anchor spaces public boolean startPier(int anchorSpot); 11 Ship is done at the pier, put into an anchor spot. 1 Note that the ship must be anchored after they use the public boolean donePier(); ier

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

More Books

Students also viewed these Databases questions

Question

Define capital structure.

Answered: 1 week ago

Question

List out some inventory management techniques.

Answered: 1 week ago