Create a new Java Project in your Eclipse workspace named as before, smith11 or jones11 for example. Create a package with the very same name as your project name. In this one package, write one Java program for the exercise as required below.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Hello I am stuck on my hw problem any help would be greatly appreciated!! Thank you so much!!

Please attach code & a screenshot of the code so I can learn!!!

I will attach the image as well

Details: 

  • Create a new Java Project in your Eclipse workspace named as before, smith11 or jones11 for example.
  • Create a package with the very same name as your project name.
  • In this one package, write one Java program for the exercise as required below.
  • Adhere to naming conventions for variables and classes
  • Choose descriptive variable names and identifiers.
  • Add a few more comments in each program to explain what your code is doing.

1. Create the four data classes as above. (Image included) Do NOT add any attributes or methods that don't appear in the UML diagrams. Create another, executable class named ShipTest as shown below to test these classes.

In ShipTest:

  • make two objects with declared type Ship but actual type CruiseShip.
  • make one object of declared type Ship but actual type CargoShip.
  • make one object of declared type CargoShip and actual type CargoShip.
  • make a ship of declared type WarShip and actual type WarShip.  
  • using the array initializer syntax, code all of these ships into an array of type Ship named fleet.
  • code a for loop that processes the fleet array to show display all ships and their data.
  • use a method of class Arrays to create an ArrayList of type Ship from the fleet array.
  • pass this ArrayList to a method named shipShow that also displays all ships and returns an integer
  • report the value of the integer returned by shipShow.

In the shipShow method:

  • from the ArrayList, remove the CargoShip that was declared as type Ship.
  • add another WarShip instance to the ArrayList.
  • use a foreach loop to process the ArrayList and print the data for each ship.
  • count the number of ships that are not afloat. Return this count to main for printing.

SAMPLE OUTPUT

AN ARRAY OF SHIPS IN MAIN
 
Ship name: Magic, year launched: 1998, is afloat: true
2700 passenger capacity, operating in the Caribbean
Ship name: Titanic, year launched: 1912, is afloat: false
1300 passenger capacity, operating in the Atlantic Ocean
Ship name: El Faro, year launched: 1974, is afloat: false
Capacity of containers is 391
Ship name: Seawise Giant, year launched: 1979, is afloat: false
Capacity of crude oil is 564763
Ship name: USS Nimitz, year launched: 1972, is afloat: true
Type: super carrier, operated by United States Navy
 
ARRAYLIST OF SHIPS FROM A METHOD
 
Ship name: Magic, year launched: 1998, is afloat: true
2700 passenger capacity, operating in the Caribbean
 
Ship name: Titanic, year launched: 1912, is afloat: false
1300 passenger capacity, operating in the Atlantic Ocean
 
Ship name: Seawise Giant, year launched: 1979, is afloat: false
Capacity of crude oil is 564763
 
Ship name: USS Nimitz, year launched: 1972, is afloat: true
Type: super carrier, operated by United States Navy
 
Ship name: USS John Warner, year launched: 2015, is afloat: true
Type: attack submarine, operated by United States Navy
 
2 of these ships sank!
<<Java Class>>
© Ship
chap11new
o name: String
- year: int
o isAfoat: boolean
SShip(String.int,boolean)
isAfoat():boolean
o setAfoat(boolean):void
getName():String
o getYear():int
o toString():String
<«Java Class>>
<<Java Class>>
<«Java Class>>
©Cruise Ship
©WarShip
©CargoShip
chap11new
chap11new
chap11new
o passengers: int
o zone: String
SCruiseShip(String, int, boolean,int, String)
• getPassengers():int
getZone():String
o toString():String
o type: String
o nation: String
SWarShip(String, int, boolean, String, String)
toString():String
o cargo: String
сарacity: int
SCargoShip(String.int,boolean, String.int)
toString):String
getCapacity():int
Transcribed Image Text:<<Java Class>> © Ship chap11new o name: String - year: int o isAfoat: boolean SShip(String.int,boolean) isAfoat():boolean o setAfoat(boolean):void getName():String o getYear():int o toString():String <«Java Class>> <<Java Class>> <«Java Class>> ©Cruise Ship ©WarShip ©CargoShip chap11new chap11new chap11new o passengers: int o zone: String SCruiseShip(String, int, boolean,int, String) • getPassengers():int getZone():String o toString():String o type: String o nation: String SWarShip(String, int, boolean, String, String) toString():String o cargo: String сарacity: int SCargoShip(String.int,boolean, String.int) toString):String getCapacity():int
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 6 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY