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

  2. Each Havu has its own ongme, which is a list of strings. The value of ongme starts out as an empty mutable list. Anyone can ask a Havu for the value of its ongme. Anyone can set ongme to a new value.

Solution

public class Havu {
    private final List<String> ongme;

    public Havu() {
    }

    public List<String> getOngme() {
        return ongme;
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: