Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Final Assignment ( 8 5 points ) Please complete the code to satisfy the following requirements: Create an interface Inhabitable that has one method lifeForm

Final Assignment (85 points)
Please complete the code to satisfy the following requirements:
Create an interface Inhabitable that has one method lifeForm() that returns void.
Create an abstract CelestialObject class that implements Inhabitable and has an attribute celestialObjectType of type String. The celestialObjectType is set through the constructor. Provide the get for the attribute.
The lifeForm() method will print a trace message in this format: name of the current class name of the current method your last name. Replace the class and the method with the actual class and method and name where you print the trace. For example: classA function1 Romano
Create a Planet class that extends CelestialObject class and has the following attributes: planetName string, numberOfMoons integer, PlanetType that can be terrestrial or Jovian, celestialObjectType should be hardcoded as the string planet.
Provide a constructor for the Planet class, that takes the 3 parameters: planet name, number of moons and type.
Validate the parameters:
If the planetName or the planetType is missing throw an InvalidArgumentException.
If the planetName attribute length is more than 30 char throw an InvalidPlanetNameException checked exception create exception class.
If the planetMoons attribute value is more than 200 throw an InvalidNumberOfMoonsException unchecked exception create exception class.
If the planetType is not terrestrial or Jovian throw an InvalidPlanetTypeException unchecked exception create exception class.
The checked exception should be thrown all the way to main().
For the Planet class:
Create the gets and the sets for the 3 attributes.
Set the numbers and constants for validations in a static initializer block.
Override equals() to compare two planet instances, based on the name, moons and type.
Override the associated function for equals().
Override ToString() to display the class data in the format NAME type moons. Example: EARTH terrestrial 0 moons. Note the name is capitalized.
COMP2601 Final Exam Page 3 of 4 June 2024
Create a Singleton Planets class that would always return the same instance of the Planets class. It will also return the same List of Planets.
Create a PlanetsMain class with a main() that would call the following functions to display the results.
In PlanetsMain, create the following methods using Stream:
Method name
Parameters
Return
Resulting behavior
printAllPlanetsByName
none
List of Planet information
EARTH terrestrial 0 moons
Capitalize the Name
Prints all planet information sorted by the name ascending. Format to output:
List of planets sorted by Name
=========================
EARTH terrestrial 0 moons
...
printAllPlanetsByMoons
none
List of Planet information
EARTH terrestrial 0 moons
Capitalize the Name
Prints all planet information sorted by the number of moons descending. Format to output:
List of planets sorted by Moons
=========================
EARTH terrestrial 0 moons
...
printPlanetsByType
planetType
List of Planets of the required type
Prints the planets of the type provided. If the type is terrestrial print:
Terrestrial planets
==============
Planet1
...
printPlanetMaxMoons
none
Name of planet and no of moons
Prints the info for the planet with the most moons
EARTH terrestrial 0 moons
COMP2601 Final Exam Page 4 of 4 June 2024
In main():
1. Print your name and student number.
2. Print how many planets are in the list.
3. Print the list of planets sorted by name, with title.
4. Print the list of planets sorted by the number of moons descending, with title.
5. Print the list of the terrestrial planets, with title.
6. Print the list of the Jovian planets, with title.
7. Trigger the 3 types of errors and print a message to prove.
Format your output for readability. Leave one empty line between the sections. Start the section with the title. For example:
Create Unit Tests for the first two methods. Save the unit tests in a tests package marked for tests should be green.
Create the UML class diagram for the requirements and upload it as pdf Optional 5p

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions