Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

QUESTION 2 ( 2 5 Marks ) Imagine you have been contracted to develop a piece of Java software for the ICESAT company. ICESAT place

QUESTION 2(25 Marks)
Imagine you have been contracted to develop a piece of Java software for the ICESAT company. ICESAT place satellites in earth orbit to monitor the condition of ice flows and icebergs across the world.
You have been tasked with creating a piece of software to store information on a number of icebergs around the world, in order to provide a warning system to any ships at sea if they sail too close to the known location of an iceberg. You have been asked to use the Java programming language.
2.a Write a Java class to represent an Iceberg. This class should contain instance variables to hold the following pieces of information. Be careful to choose the best types to hold this information, and ensure your class is properly encapsulated.
A number that identifies the iceberg (you may assume this is a whole number).
The size of the iceberg recorded as its maximum diameter in metres.
The location of the centre of the iceberg, using simple x and y coordinates.
[4 Marks]
2.b Write an appropriate constructor for your Iceberg class.
[3 Marks]
2.c You have also been asked to store information on all ships registered with ICESAT. Write another class called Ship. Each ship has a name, length (in metres) and a location also represented using simple x and y co-ordinates. Create an appropriate constructor for this class.
[3 Marks]
2.d Write one further class that represents the Earth. This should contain two arrays as instance variables - an array of all the icebergs on the Earth, and an array of all the known ships. For the purpose of this exercise, you may assume that there will only be a maximum of three ships and three icebergs.
[4 Marks]
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions