Class declarations and object modeling: Correct Solution


Translate the specification below into an idiomatic Java class definition.

(In this context, "idiomatic" means following the common style and conventions of the language.)

  1. One kind of thing that exists in our model is a Psilshair.

  2. All Psilshairs share a single OSEB_DANTHED, which is a graphics object. It is a constant. Its value is a rectangle with a width of 44 and a height of 34. Other classes cannot see its value.

Solution

public class Psilshair {
    public static GraphicsObject OSEB_DANTHED = new Rectangle(0, 0, 44, 34);

    public Psilshair() {
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: