|
4 | 4 | @author: Aseem Jain
|
5 | 5 | @title: Design Patterns with Java 9
|
6 | 6 | @link: https://premaseem.wordpress.com/category/computers/design-patterns/
|
7 |
| -@copyright: 2018 Packt Publication |
8 | 7 | */
|
9 | 8 | public class Client {
|
10 | 9 | public static void main (String[] args) {
|
11 |
| - System.out.println("Singleton cook example "); |
| 10 | + System.out.println("Flyweight design pattern using ** STAR WARS ** example"); |
| 11 | + |
| 12 | + // Created 1000 stars with brightness level bright |
| 13 | + Star brightStar1 = new Star("bright"); |
| 14 | + Star brightStar2 = new Star("bright"); |
| 15 | + Star brightStar3 = new Star("bright"); |
| 16 | + Star brightStar4 = new Star("bright"); |
| 17 | + Star brightStar5 = new Star("bright"); |
| 18 | + Star brightStar1000 = new Star("bright"); |
| 19 | + |
| 20 | + // Created 1000 stars with brightness level dim |
| 21 | + Star dimStar1 = new Star("dim"); |
| 22 | + Star dimStar2 = new Star("dim"); |
| 23 | + Star dimStar3 = new Star("dim"); |
| 24 | + Star dimStar4 = new Star("dim"); |
| 25 | + Star dimStar5 = new Star("dim"); |
| 26 | + Star dimStar1000 = new Star("dim"); |
| 27 | + |
| 28 | + // Created 1000 stars with brightness level dull |
| 29 | + Star dullStar1 = new Star("dull"); |
| 30 | + Star dullStar2 = new Star("dull"); |
| 31 | + Star dullStar3 = new Star("dull"); |
| 32 | + Star dullStar4 = new Star("dull"); |
| 33 | + Star dullStar5 = new Star("dull"); |
| 34 | + Star dullStar1000 = new Star("dull"); |
| 35 | + |
| 36 | + // Create Landscape object which is responsible to display stars |
| 37 | + Landscape landscape = new Landscape(); |
| 38 | + |
| 39 | + landscape.displayStar(brightStar1,34,45); |
| 40 | + landscape.displayStar(brightStar2,34,45); |
| 41 | + landscape.displayStar(brightStar3,23,65); |
| 42 | + landscape.displayStar(brightStar1000,34,45); |
| 43 | + |
| 44 | + landscape.displayStar(dimStar1,34,45); |
| 45 | + landscape.displayStar(dimStar2,54,45); |
| 46 | + landscape.displayStar(dimStar3,34,45); |
| 47 | + landscape.displayStar(dimStar4,34,45); |
| 48 | + landscape.displayStar(dimStar1000,34,45); |
| 49 | + |
| 50 | + landscape.displayStar(dullStar1,87,90); |
| 51 | + landscape.displayStar(dullStar2,34,45); |
| 52 | + landscape.displayStar(dullStar3,23,55); |
| 53 | + landscape.displayStar(dullStar1000,34,45); |
12 | 54 | }
|
13 | 55 | }
|
0 commit comments