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.
 
 
 
 
 
 
Abdelilah Khossan 78e9c1846c
CON-1881-Review-java-piscine-subjects-Fix-grammar-and-semantic-issues (#2102)
1 year ago
..
README.md CON-1881-Review-java-piscine-subjects-Fix-grammar-and-semantic-issues (#2102) 1 year ago

README.md

Singleton

Instructions

In this quest, we will implement some design patterns.

At 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 getInstance method, an instance of Excalibur with name "Sword" should be returned.

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