Question: Instructions In this lab, we will define and develop TWO Java classes: Star and Galaxy. Follow the requirements below to complete your homework assignment. The
Instructions
In this lab, we will define and develop TWO Java classes: Star and Galaxy.
Follow the requirements below to complete your homework assignment.
The class Star should contain several basic features of a star such as its name String diameter double age int surface temperature double etc.
The class Galaxy should reuse the class Star by COMPOSITION ie you should make an array of Star objects as an instance variable in the Galaxy class and define some additional features such as the name of the galaxy String number of stars int the diameter of the galaxy double etc.
BOTH CLASSES should contain at least two constructors including the copyconstructor for Star class and a pair of setget methods accessor and mutator methods for each data field, and the toString method for both of them.
Also include a main method to build up ONE galaxy with at least three stars. You should also be able to print out all the info either to the console or using the popup window.
Please make sure that your Java classes are properly indented and also include comments as necessary to clearly indicate the different functional blocks as well as the usage of methods. CANNOT USE CHATGPT
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
