Create in your a1 directory a class named Earth that has the following properties:
- No instances of the class can be created
- The class has a public field named RADIUS that holds a constant value of 3959.
Create in your a1 directory an enumeration named FamousDogs that has the following properties:
- The enumeration has instances named BEETHOVEN, AIRBUD, SCOOBY-DOO and COURAGE.
Create in your a1 directory an enumeration named Planets that has the following properties:
- Each planet (Mercury, Venus, …) is named and is created by a constructor with a single double parameter. The constructor sets a private field named distanceFromEarth (you’ll have to look up the values).
- The enumeration has a public method named getDistanceFromEarth that returns, take a guess, the distance from earth stored in the private field.
Create a directory named a3-v2 and in it, write a driver class named Driver. The driver should do the following:
- Print the radius of Earth using the Earth class.
- Print the names of the famous dogs declared in FamousDogs using the values method.
- Print the distance between Mars and Earth using the Planets type.
© 2017 – 2019, Eric. All rights reserved.