forked from premaseem/DesignPatternsJava9
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCook.java
More file actions
33 lines (25 loc) · 637 Bytes
/
Copy pathCook.java
File metadata and controls
33 lines (25 loc) · 637 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.premaseem;
/*
@author: Aseem Jain
@title: Design Patterns with Java 9
@link: https://premaseem.wordpress.com/category/computers/design-patterns/
@copyright: 2018 Packt Publication
*/
public class Cook {
private Cook(){
}
private static Cook uniqueInstance = null;
public static Cook getInstance(){
if(uniqueInstance == null){
uniqueInstance = new Cook();
}
return uniqueInstance;
}
boolean saltAdded = false;
public void makeBroth(){
if(!saltAdded){
System.out.println("adding salt");
saltAdded = true;
}
}
}