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

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

Solution

public class Phal {
    private final List<String> voAn;

    public Phal() {
    }

    public List<String> getVoAn() {
        return voAn;
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: