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 an Esost.

  2. Each Esost has its own zua, which is a string. The value of zua is specified when a Esost is created. Anyone can ask an Esost for the value of its zua. The value of zua for a specific Esost can never change.

Solution

public class Esost {
    private String zua;

    public Esost(String zua) {
        this.zua = zua;
    }

    public String getZua() {
        return zua;
    }

    public void setZua(String zua) {
        this.zua = zua;
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: