Starting from:

$30

CSI 405 - Homework 3 - Solved

  

Object Oriented Programming 
Problem 1 (edu.albany.cruise, edu.albany.cargo) Model Ship, CruiseShip and CargoShip classes 
Design a ship class that has the following members:

1.       A field for the name of the ship (string)

2.       A field for the year that the ship was built (string)

3.       A constructor and appropriate accessors and mutators

4.       A toString method that displays the ship’s name and the year it was built

Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members:

1.       A field for the maximum number of passengers (int)

2.       A constructor and appropriate accessors and mutators

3.       A toString method that overrides the toString method in the base class. The CruiseShip 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 habe the following members:

1.       A field for the cargo capacity in tonnage (int)

2.       A constructor and appropriate accessors and mutators

3.       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, CruiseShip and CargoShip objects to the array elements. The program should then step through the array, calling each object’s 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:

1.       Create a sequence / flow diagram – This diagram would show how an interaction is initiated. Also it shows which class will initiate which other class

2.       Indicate what information (if any) is passed between the classes

3.       Figure out what instance variables will be needed in each of the classes

4.       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.

5.       Create all the classes

6.       Create a driver class (SandwichDriver) to test the functionality

7.       Handle all possible errors with try catch blocks wherever necessary


More products