Singleton - Sam647254/Programetoj GitHub Wiki
Java
public final class Waterpark {
private static final Waterpark INSTANCE = new Waterpark();
private Singleton() { }
public void water() { }
public void park() { }
public static Waterpark getInstance() { return Waterpark; }
}
// main
class Example {
public static void main(String[] arguments) {
var waterpark = Waterpark.getInstance();
waterpark.water();
waterpark.park();
}
}
TypeScript
const waterpark = {
water() { }
park() { }
};
// main
waterpark.water();
waterpark.park();