Question: Hey Chegg, I am currently having a hard time completing this assignment in Java: Create a class named Planet. The class should have private fields

Hey Chegg,

I am currently having a hard time completing this assignment in Java:

Create a class named Planet. The class should have private fields that describe a single planet in our solar system. Include these private class fields:

name

mass

radius

minimum distance from the sun

maximum distance from the sun

type

Include these methods in your Planet class:

getter and setter methods for each of the private data fields

a no-arg constructor

a constructor that takes arguments to initialize all of the fields

a toString method that returns a string containing the name of the planet

When you have a usable class definition for Planet, write another class with a public static void main method to test your implementation of Planet. Have it create an instance for each planet in our solar system, and store references to each in an ArrayList of Planet. Then loop through the array, and printing each planet. Write your print statement such that it uses the toString method of the Planet 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!