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

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

Solution

public class Wrodglem {
    private GraphicsObject haSas;

    public Wrodglem(GraphicsObject haSas) {
        this.haSas = haSas;
    }

    public GraphicsObject getHaSas() {
        return haSas;
    }

    public void setHaSas(GraphicsObject haSas) {
        this.haSas = haSas;
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: