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

  2. Each Gecfat has its own enIndos, which is a string. The value of enIndos starts out as "pe". Anyone can ask a Gecfat for the value of its enIndos. Anyone can set enIndos to a new value.

Solution

public class Gecfat {
    private final String enIndos;

    public Gecfat() {
    }

    public String getEnIndos() {
        return enIndos;
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: