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

  2. Each Quess has a telo, which is a list of strings. A telo is part of the internal state of a Quess: no other classes can see the value of telo or directly change it. When a Quess is first created, the value of its telo starts out as an empty mutable list.

Solution

public class Quess {
    public List<String> telo = new ArrayList<>();

    public Quess() {
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: