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

  2. Each Twiess has a scet, which is a string. A scet is part of the internal state of a Twiess: no other classes can see the value of scet or directly change it. When a Twiess is first created, the value of its scet starts out as "el".

Solution

public class Twiess {
    public String scet = "el";

    public Twiess() {
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: