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

  2. Each Herphoal has its own pisi, which is a list of strings. The value of pisi is specified when a Herphoal is created. Anyone can ask a Herphoal for the value of its pisi. The value of pisi for a specific Herphoal can never change.

Solution

public class Herphoal {
    private List<String> pisi;

    public Herphoal(List<String> pisi) {
        this.pisi = pisi;
    }

    public List<String> getPisi() {
        return pisi;
    }

    public void setPisi(List<String> pisi) {
        this.pisi = pisi;
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: