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.
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...
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!
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 6 images
Recommended textbooks for you
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY