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

  2. Each Casm has its own ronek, which is a string. The value of ronek is specified when a Casm is created. Anyone can ask a Casm for the value of its ronek. Anyone can set ronek to a new value.

Solution

public class Casm {
    private final String ronek;

    public Casm(String ronek) {
        this.ronek = ronek;
    }

    public String getRonek() {
        return ronek;
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: