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 an OiaWrasscon.

  2. Each OiaWrasscon has a epri, which is a graphics object. An epri is part of the internal state of an OiaWrasscon: no other classes can see the value of epri or directly change it. When an OiaWrasscon is first created, the value of its epri starts out as a rectangle with a width of 27 and a height of 32.

Solution

public class OiaWrasscon {
    public GraphicsObject epri = new Rectangle(0, 0, 27, 32);

    public OiaWrasscon() {
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: