Problem 1 (edu.albany.cruise, edu.albany.cargo)

Model Ship, CruiseShip and CargoShip classes

Design a ship class that has the following members:

  • A field for the name of the ship (string)
  • A field for the year that the ship was built (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 (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 habe the following members:

  • A field for the cargo capacity in tonnage (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

Demonstrate the classes in a program that has a Ship array. Assign various Ship, CruiseShip and CargoShip objects to the array elements. The program should then step through the array, calling each objects toString method.

Problem 2 (edu.albany.your_package_names)

Create packages as needed per design

Create classes modeling the purchase of sandwich / sandwiches at a typical sandwich shop. Use three objects: Cashier, Customer, SandwichMaker. (You can add more classes if you want but these three should be present in the project)

Follow the steps to complete the homework:

  • Create a sequence / flow diagram This diagram would show how an interaction is initiated. Also it shows which class will initiate which other class
  • Indicate what information (if any) is passed between the classes
  • Figure out what instance variables will be needed in each of the classes
  • Create UML diagrams - The UML diagrams should follow the exact formatting shown in class slides. Submit UML diagrams in a separate folder as images with your code submission.
  • Create all the classes
  • Create a driver class (SandwichDriver) to test the functionality
  • Handle all possible errors with try catch blocks wherever necessary
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.