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 Froc.

  2. Each Froc has its own itUdod, which is a graphics object. The value of itUdod is specified when a Froc is created. Anyone can ask a Froc for the value of its itUdod. The value of itUdod for a specific Froc can never change.

Solution

public class Froc {
    private GraphicsObject itUdod;

    public Froc(GraphicsObject itUdod) {
        this.itUdod = itUdod;
    }

    public GraphicsObject getItUdod() {
        return itUdod;
    }

    public void setItUdod(GraphicsObject itUdod) {
        this.itUdod = itUdod;
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: