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

  2. All Gantsoipss share a single priui, which is a string. No other classes can directly ask for the value of priui. The value of priui starts out as "luntown" when the program starts. Every time a new Gantsoips is created, it adds "ses" to priui.

Solution

public class Gantsoips {
    public static String priui;

    public Gantsoips() {
        priui += "ses";
    }

    public static void onStart() {
        priui = "luntown";
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: