Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA Draw the UML for the following classes, except Launch, being sure to show the aggregation lines and diamonds. Then do the program. The following
JAVA
Draw the UML for the following classes, except Launch, being sure to show the aggregation lines and diamonds.
Then do the program.
The following program is made up of four classes, Country, Satellite, SatConstellation, and Launch. You can use satellites.txt found in ProgramsLesson Hpmework tab as the input file.
Submit the UML for Country, Satellite and SatConstellation showing the aggregation via appropriate connector.
each of the four classes as a separate java file.
class Country
Has an instance variable:
String countryName the name of the Country
Default constructor sets the countryName to unknown by calling the mutator method for the variable
A constructor with the Countrys name as an input variable which:
Calls a mutator to set the Countrys name
Methods:
Mutators and accessors for countryName
A toString method that returns the String as follows name will change:
The Country for the Constellation is United States
class Satellite
Has a static variable randy of type Random with a seed of
Has two instance variables:
String satelliteName the name of the Satellite
int satelliteOrbitHeight the height of the satellites orbit in miles
Default constructor sets the satelliteName to unknown by calling the mutator method for the variable
A constructor with the Satellites name as an input variable which:
Calls a mutator to set the Satellites name
Calls a mutator to set the Satellites satelliteOrbitHeight in miles with a randomly generated height of between and miles, inclusively means both and are included
Methods:
Mutators and accessors for the satelliteName and satelliteOrbitHeight
A toString method that returns the String as follows name height will change:
The satellite named Tesla has an orbital height of miles.
An equals method that compares two satellites based on both name and orbital height.
class SatConstellation
Has the following three instance variables:
String satConstellationName
Country country
An ArrayList containing references to Satellite objects named satelliteList
A default constructor that:
Sets the satConstellationName name to unknown by calling the mutator method for the variable
Calls the default Country construct to create a Country referred to by country
A constructor with two parameters for the SatConstellation name and its Countrys name which:
Calls a mutator to set the SatConstellation s name
Creates a Country referred to by country by calling a Country constructor with the Countrys name.
Calls createSatellites see below to create the satellites.
Methods:
A mutator and accessor for the SatConstellation name.
A toString method that returns a String with output to produce the output except for the equals statements as shown in Sample output. Includes the Countrys name, Satellites name, and the name and height for each Satellite.
The createSatellites method with no parameters and a void return value which:
Creates a Scanner to read data from the keyboard.
Reads in a file name with the names of the Satellites.
Creates a Scanner for the satellite names file.
For each satelliteName create a Satellite and add it to the ArrayList satelliteList.
The getNumSatellites method with no parameters which return the size of the satelliteList.
The getSatellite method which accepts an int index as a parameter and returns null or a reference to a Satellite as follows:
If the index is out of range for the satelliteList print:
Satellite doesn't exist
Return null
Otherwise return reference to the Satellite at the index.
class Launch
Has a main method only.
Creates a Scanner to read from the keyboard
Reads in the name of the Country and the name of the SatConstellation
Create a new SatConstellation with the Country and SatConstellation name.
Print out the SatConstellation
If there is more than one Satellite
Compare each satellite except the first satellite in the SatConstellation of the first satellite in the ArrayList.
If any satellite equals the first satellite
Print it out
otherwise
Print: There is no satellite that matches the first satellite
Then set the name and maximum orbital height of the last satellite to the first satellite
Then see if the two satellites are equal and print as follows:
The satellite named SpaceX MARS Node has a maximum orbital height of miles and equals the first satellite in the ArrayList
else
Print There are no satellites to compare
A sample inputoutput may look like below. Part in italics is what the toString in SatConstellation returns. Since
Please enter the name of the Country: United States
Please enter the name of the Satellite Constellation SpaceX Starlink
Please enter file to read in Satellite List from: satellites.txt
The name of United States's satellite constellat
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started