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

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

Solution

public class Istis {
    private final String sca;

    public Istis(String sca) {
        this.sca = sca;
    }

    public String getSca() {
        return sca;
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: