You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
davhojt 1cf114eb85
docs(java): move piscine exercises from subjects/java-piscine -> subjects/java/piscine
1 year ago
..
README.md docs(java): move piscine exercises from subjects/java-piscine -> subjects/java/piscine 1 year ago

README.md

Singleton

Instructions

In this quest, we will implement some design patterns.

For first, we will implement the singleton pattern.

classDiagram
class Excalibur{
    -String name
    -Excalibur INSTANCE$
    -Excalibur(String name)
    +getName() String
    +getInstance()$ Excalibur
}
Excalibur <-- Excalibur

Here is the matching class diagram. Create the matching class in the matching file.

When calling the getInstance method, an instance of Excalibur with name "Sword"

Usage

Here is a possible ExerciseRunner.java to test your function :

public class ExerciseRunner {

    public static void main(String[] args)  {
        System.out.println(Excalibur.getInstance().getName());
    }
}

and its output :

$ javac *.java -d build
$ java -cp build ExerciseRunner 
Sword
$

Notions

Class diagram