A3 ‣ Static Members and Enumerations

In your directory named a1 create a class named UnitCircle that has the following members:

  1. An constant integer field named radius is initialized to the value of the radius of a unit circle.
  2. A constant field that is named area that is initialized in a static block to the value of the area of a unit circle.
  3. A constant field that is named circumference that is initialized in a static block to the value of the circumference of a unit circle.
  4. A default constructor that can not be called from outside the UnitCircle class.

Write the class so that the class is in a package and may be used by other classes outside of UnitCircle’s package.

Create a directory named a3 and within it, write a program named Driver that uses the UnitCircle class to print the radius, area, and circumference of a UnitCircle.


In your directory named a1 crate an enumeration named Color that has the following properties:

  1. It names three constants named Red, Blue, and Yellow.
  2. It has a String field named HTMLColorCode.
  3. It has a custom constructor that has a single String parameter and which sets field named HTMLColorCode equal to the value passed in as an argument.
  4. It has a method named getHTMLColorCode that returns the value stored in the field HTMLColorCode.

In your Driver (in a3) create an instance of Red, Blue and Yellow and print their HTML color codes.

© 2017 – 2019, Eric. All rights reserved.