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

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

Solution

public class Zess {
    public String rehas = "iaec";

    public Zess() {
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: