How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask LogicPro Your Own Question
LogicPro
LogicPro, Computer Software Engineer
Category: Programming
Satisfied Customers: 12991
Experience:  Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.
29751445
Type Your Programming Question Here...
LogicPro is online now
A new question is answered every 9 seconds

Design a Ship class that the following members: • A field

This answer was rated:

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 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:
• 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 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 or arrayList. 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.

LogicPro :

hi

Customer:

Hello

LogicPro :

My name is XXXXX XXXXX I will help you.

LogicPro :

When do you need it?

Customer:

By 11pm est tonight if possible

LogicPro :

In how many hours?

Customer:

It's about 10 hours

LogicPro :

I will provide you answer ASAP.

Customer:

I appreciate it.

LogicPro :

thank you

LogicPro :

Download this zip file. Ship_Java.zip

LogicPro :

Unzip to get all the java files.

LogicPro :

Run ShipMain.java file.

LogicPro :

You can ask me again using "For LogicPro only" at the start of your questions like other customers to get instant and fresh answers. Please leave a positive feedback/bonus after clicking ACCEPT and ask me if you need more info.

Customer:

One thing I'm confused about is how does it interact with the other files, we're expected to do this in class as well, and I don't quite understand

LogicPro :

please wait.

LogicPro and 3 other Programming Specialists are ready to help you
Classes are intereacting usning constructors. See in class CruiseShip, when you pass values to constructor, the constructor passes to parameters to super class constructor:
public CruiseShip (int mp, String n, String y)
{
super(n,y);
maxPasangers = mp;
}
LogicPro and 3 other Programming Specialists are ready to help you