docs: adding more details

This commit is contained in:
zanninso 2024-07-18 04:10:03 +01:00 committed by zanninso
parent a4e4dcc580
commit a89a441036
2 changed files with 7 additions and 3 deletions

View File

@ -1,4 +1,5 @@
public class ExerciseRunner { public class ExerciseRunner {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(Singleton.get???().whoAreYou());
} }
} }

View File

@ -2,7 +2,7 @@
### Instructions ### Instructions
You are given an incomplete singleton class. Complete the class to demonstrate your understanding of how the Singleton design pattern works. The Singleton pattern ensures that a class has only one instance and provides a global point of access to that instance. You are given an incomplete `Singleton` class. Complete the class to demonstrate your understanding of how the `Singleton` design pattern works. The `Singleton` pattern ensures that a class has only one instance and provides a global point of access to that instance.
### Expected Class ### Expected Class
@ -11,11 +11,13 @@ public class Singleton {
public Singleton instance; public Singleton instance;
private Singleton() { private Singleton() {
// Initialization code
} }
public Singleton get???() { public Singleton get???() {
// Implementation to return the single instance }
public String whoAreYou() {
return "Hello, I am a singleton!"
} }
} }
``` ```
@ -27,6 +29,7 @@ Here is a possible `ExerciseRunner.java` to test your class:
```java ```java
public class ExerciseRunner { public class ExerciseRunner {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(Singleton.get???().whoAreYou());
} }
} }
``` ```