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

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

Solution

public class Swamos {
    private final List<String> crist;

    public Swamos() {
    }

    public List<String> getCrist() {
        return crist;
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: