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

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

Solution

public class AthLusschroel {
    private int caNaod;

    public AthLusschroel(int caNaod) {
        this.caNaod = caNaod;
    }

    public int getCaNaod() {
        return caNaod;
    }

    public void setCaNaod(int caNaod) {
        this.caNaod = caNaod;
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: