Question: Here's the project: Create a simple command line Java program to model our solar system and another fictional solar system. To complete this project you

Here's the project: Create a simple command line Java program to model our solar system and another fictional solar system. To complete this project you will need to create 3 separate java files:

A Planet Class: this file should be a class that contains at least 2 private attributes or properties. The first attribute should be for the name of the planet and the second number for the number of moons that planet has. This class should have a parameterized constructor, "setters and getters" for the attributes, and finally, a "toString" method that returns the name and the number of moons.

A SolarSystem Class: this file should be a class with two private attributes. The first attribute is again a name for the solar system. The second attribute should be an array of planet objects(instances of the above class). The class should have parameterized constructor that accepts an int for the size fo the solar system (the number of planets it can hold) and a String for the name. There should be setters and getters for name attribute, however, the accessor methods for an array of planets should be limited to inserting a planet at a certain index (place) in the array and retrieving a planet by index (position). Additionally, include methods that return the number of planets in the solar system and the total number of moons within the solar system. Finally, the Solar System class should have a method that prints out all of the planets it contains and the number of their moons (the toString method for each planet should be called).

A Driver Class: this file should contain a main method that:

1) Instantiates 2 solar systems

2) Creates and inserts planets into the solar systems

3) Prints the name of each solar system, the number of planets, the total number of its moons, and finally each of its planets (along with their moon count)

Only the driver class should have a main method. Additionaly their is no need for user interaction with this program(Scanner or argc). All of the planet data should be hard-coded into the driver class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!