-
+{
Item next();
boolean hasNext();
diff --git a/Mediator/src/Alarm.java b/Mediator/src/Alarm.java
index 388a603..4500df8 100644
--- a/Mediator/src/Alarm.java
+++ b/Mediator/src/Alarm.java
@@ -1,11 +1,14 @@
-public class Alarm extends Colleague {
+public class Alarm extends Colleague
+{
@Override
- public void onEvent(Mediator mediator) {
+ public void onEvent(Mediator mediator)
+ {
mediator.doEvent("alarm");
}
- public void doAlarm() {
+ public void doAlarm()
+ {
System.out.println("doAlarm()");
}
}
diff --git a/Mediator/src/Calender.java b/Mediator/src/Calender.java
index 579ca8a..e638784 100644
--- a/Mediator/src/Calender.java
+++ b/Mediator/src/Calender.java
@@ -1,10 +1,13 @@
-public class Calender extends Colleague {
+public class Calender extends Colleague
+{
@Override
- public void onEvent(Mediator mediator) {
+ public void onEvent(Mediator mediator)
+ {
mediator.doEvent("calender");
}
- public void doCalender() {
+ public void doCalender()
+ {
System.out.println("doCalender()");
}
}
diff --git a/Mediator/src/Client.java b/Mediator/src/Client.java
index a734346..0c687e8 100644
--- a/Mediator/src/Client.java
+++ b/Mediator/src/Client.java
@@ -1,5 +1,7 @@
-public class Client {
- public static void main(String[] args) {
+public class Client
+{
+ public static void main(String[] args)
+ {
Alarm alarm = new Alarm();
CoffeePot coffeePot = new CoffeePot();
Calender calender = new Calender();
diff --git a/Mediator/src/CoffeePot.java b/Mediator/src/CoffeePot.java
index 6facf46..a056ed2 100644
--- a/Mediator/src/CoffeePot.java
+++ b/Mediator/src/CoffeePot.java
@@ -1,10 +1,13 @@
-public class CoffeePot extends Colleague {
+public class CoffeePot extends Colleague
+{
@Override
- public void onEvent(Mediator mediator) {
+ public void onEvent(Mediator mediator)
+ {
mediator.doEvent("coffeePot");
}
- public void doCoffeePot() {
+ public void doCoffeePot()
+ {
System.out.println("doCoffeePot()");
}
}
diff --git a/Mediator/src/Colleague.java b/Mediator/src/Colleague.java
index 15aef81..284efd1 100644
--- a/Mediator/src/Colleague.java
+++ b/Mediator/src/Colleague.java
@@ -1,3 +1,4 @@
-public abstract class Colleague {
+public abstract class Colleague
+{
public abstract void onEvent(Mediator mediator);
}
diff --git a/Mediator/src/ConcreteMediator.java b/Mediator/src/ConcreteMediator.java
index b170cf2..e8fc9f3 100644
--- a/Mediator/src/ConcreteMediator.java
+++ b/Mediator/src/ConcreteMediator.java
@@ -1,10 +1,12 @@
-public class ConcreteMediator extends Mediator {
+public class ConcreteMediator extends Mediator
+{
private Alarm alarm;
private CoffeePot coffeePot;
private Calender calender;
private Sprinkler sprinkler;
- public ConcreteMediator(Alarm alarm, CoffeePot coffeePot, Calender calender, Sprinkler sprinkler) {
+ public ConcreteMediator(Alarm alarm, CoffeePot coffeePot, Calender calender, Sprinkler sprinkler)
+ {
this.alarm = alarm;
this.coffeePot = coffeePot;
this.calender = calender;
@@ -12,7 +14,8 @@ public ConcreteMediator(Alarm alarm, CoffeePot coffeePot, Calender calender, Spr
}
@Override
- public void doEvent(String eventType) {
+ public void doEvent(String eventType)
+ {
switch (eventType) {
case "alarm":
doAlarmEvent();
@@ -28,22 +31,26 @@ public void doEvent(String eventType) {
}
}
- public void doAlarmEvent() {
+ public void doAlarmEvent()
+ {
alarm.doAlarm();
coffeePot.doCoffeePot();
calender.doCalender();
sprinkler.doSprinkler();
}
- public void doCoffeePotEvent() {
+ public void doCoffeePotEvent()
+ {
// ...
}
- public void doCalenderEvent() {
+ public void doCalenderEvent()
+ {
// ...
}
- public void doSprinklerEvent() {
+ public void doSprinklerEvent()
+ {
// ...
}
}
diff --git a/Mediator/src/Mediator.java b/Mediator/src/Mediator.java
index 0cb9ed4..fd52d36 100644
--- a/Mediator/src/Mediator.java
+++ b/Mediator/src/Mediator.java
@@ -1,3 +1,4 @@
-public abstract class Mediator {
+public abstract class Mediator
+{
public abstract void doEvent(String eventType);
}
diff --git a/Mediator/src/Sprinkler.java b/Mediator/src/Sprinkler.java
index 77c3bc3..c6ed705 100644
--- a/Mediator/src/Sprinkler.java
+++ b/Mediator/src/Sprinkler.java
@@ -1,10 +1,13 @@
-public class Sprinkler extends Colleague {
+public class Sprinkler extends Colleague
+{
@Override
- public void onEvent(Mediator mediator) {
+ public void onEvent(Mediator mediator)
+ {
mediator.doEvent("sprinkler");
}
- public void doSprinkler() {
+ public void doSprinkler()
+ {
System.out.println("doSprinkler()");
}
}
diff --git a/Menento/src/Calculator.java b/Menento/src/Calculator.java
index fec8737..4b06f4d 100644
--- a/Menento/src/Calculator.java
+++ b/Menento/src/Calculator.java
@@ -1,7 +1,8 @@
/**
* Originator Interface
*/
-public interface Calculator {
+public interface Calculator
+{
// Create Memento
PreviousCalculationToCareTaker backupLastCalculation();
diff --git a/Menento/src/CalculatorImp.java b/Menento/src/CalculatorImp.java
index 8b6f37f..0e7ce8b 100644
--- a/Menento/src/CalculatorImp.java
+++ b/Menento/src/CalculatorImp.java
@@ -1,36 +1,42 @@
/**
* Originator Implementation
*/
-public class CalculatorImp implements Calculator {
+public class CalculatorImp implements Calculator
+{
private int firstNumber;
private int secondNumber;
@Override
- public PreviousCalculationToCareTaker backupLastCalculation() {
+ public PreviousCalculationToCareTaker backupLastCalculation()
+ {
// create a memento object used for restoring two numbers
return new PreviousCalculationImp(firstNumber, secondNumber);
}
@Override
- public void restorePreviousCalculation(PreviousCalculationToCareTaker memento) {
+ public void restorePreviousCalculation(PreviousCalculationToCareTaker memento)
+ {
this.firstNumber = ((PreviousCalculationToOriginator) memento).getFirstNumber();
this.secondNumber = ((PreviousCalculationToOriginator) memento).getSecondNumber();
}
@Override
- public int getCalculationResult() {
+ public int getCalculationResult()
+ {
// result is adding two numbers
return firstNumber + secondNumber;
}
@Override
- public void setFirstNumber(int firstNumber) {
+ public void setFirstNumber(int firstNumber)
+ {
this.firstNumber = firstNumber;
}
@Override
- public void setSecondNumber(int secondNumber) {
+ public void setSecondNumber(int secondNumber)
+ {
this.secondNumber = secondNumber;
}
}
\ No newline at end of file
diff --git a/Menento/src/Client.java b/Menento/src/Client.java
index c5a0d2b..052535b 100644
--- a/Menento/src/Client.java
+++ b/Menento/src/Client.java
@@ -1,9 +1,11 @@
/**
* CareTaker object
*/
-public class Client {
+public class Client
+{
- public static void main(String[] args) {
+ public static void main(String[] args)
+ {
// program starts
Calculator calculator = new CalculatorImp();
diff --git a/Menento/src/PreviousCalculationImp.java b/Menento/src/PreviousCalculationImp.java
index 0654b80..e118772 100644
--- a/Menento/src/PreviousCalculationImp.java
+++ b/Menento/src/PreviousCalculationImp.java
@@ -4,23 +4,27 @@
* Note that this object implements both interfaces to Originator and CareTaker
*/
public class PreviousCalculationImp implements PreviousCalculationToCareTaker,
- PreviousCalculationToOriginator {
+ PreviousCalculationToOriginator
+{
private int firstNumber;
private int secondNumber;
- public PreviousCalculationImp(int firstNumber, int secondNumber) {
+ public PreviousCalculationImp(int firstNumber, int secondNumber)
+ {
this.firstNumber = firstNumber;
this.secondNumber = secondNumber;
}
@Override
- public int getFirstNumber() {
+ public int getFirstNumber()
+ {
return firstNumber;
}
@Override
- public int getSecondNumber() {
+ public int getSecondNumber()
+ {
return secondNumber;
}
}
\ No newline at end of file
diff --git a/Menento/src/PreviousCalculationToCareTaker.java b/Menento/src/PreviousCalculationToCareTaker.java
index ce6167f..e14d4b7 100644
--- a/Menento/src/PreviousCalculationToCareTaker.java
+++ b/Menento/src/PreviousCalculationToCareTaker.java
@@ -1,6 +1,7 @@
/**
- * Memento interface to CalculatorOperator (Caretaker)
+ * Memento interface to CalculatorOperator (Caretaker)
*/
-public interface PreviousCalculationToCareTaker {
- // no operations permitted for the caretaker
+public interface PreviousCalculationToCareTaker
+{
+ // no operations permitted for the caretaker
}
\ No newline at end of file
diff --git a/Menento/src/PreviousCalculationToOriginator.java b/Menento/src/PreviousCalculationToOriginator.java
index 111f154..83e63b2 100644
--- a/Menento/src/PreviousCalculationToOriginator.java
+++ b/Menento/src/PreviousCalculationToOriginator.java
@@ -1,9 +1,11 @@
/**
* Memento Interface to Originator
- *
+ *
* This interface allows the originator to restore its state
*/
-public interface PreviousCalculationToOriginator {
- int getFirstNumber();
- int getSecondNumber();
+public interface PreviousCalculationToOriginator
+{
+ int getFirstNumber();
+
+ int getSecondNumber();
}
\ No newline at end of file
diff --git a/Null/src/AbstractOperation.java b/Null/src/AbstractOperation.java
index d20b7c1..6231bfc 100644
--- a/Null/src/AbstractOperation.java
+++ b/Null/src/AbstractOperation.java
@@ -1,3 +1,4 @@
-public abstract class AbstractOperation {
+public abstract class AbstractOperation
+{
abstract void request();
}
diff --git a/Null/src/Client.java b/Null/src/Client.java
index 5f45f5c..265564a 100644
--- a/Null/src/Client.java
+++ b/Null/src/Client.java
@@ -1,10 +1,13 @@
-public class Client {
- public static void main(String[] args) {
+public class Client
+{
+ public static void main(String[] args)
+ {
AbstractOperation abstractOperation = func(-1);
abstractOperation.request();
}
- public static AbstractOperation func(int para) {
+ public static AbstractOperation func(int para)
+ {
if (para < 0) {
return new NullOperation();
}
diff --git a/Null/src/NullOperation.java b/Null/src/NullOperation.java
index cad980c..b093f6a 100644
--- a/Null/src/NullOperation.java
+++ b/Null/src/NullOperation.java
@@ -1,6 +1,8 @@
-public class NullOperation extends AbstractOperation{
+public class NullOperation extends AbstractOperation
+{
@Override
- void request() {
+ void request()
+ {
// do nothing
}
}
diff --git a/Null/src/RealOperation.java b/Null/src/RealOperation.java
index f72bb05..6c0d2a0 100644
--- a/Null/src/RealOperation.java
+++ b/Null/src/RealOperation.java
@@ -1,6 +1,8 @@
-public class RealOperation extends AbstractOperation {
+public class RealOperation extends AbstractOperation
+{
@Override
- void request() {
+ void request()
+ {
System.out.println("do something");
}
}
diff --git a/Observer/src/CurrentConditionsDisplay.java b/Observer/src/CurrentConditionsDisplay.java
index 5dccb73..dd13dc1 100644
--- a/Observer/src/CurrentConditionsDisplay.java
+++ b/Observer/src/CurrentConditionsDisplay.java
@@ -1,11 +1,14 @@
-public class CurrentConditionsDisplay implements Observer {
+public class CurrentConditionsDisplay implements Observer
+{
- public CurrentConditionsDisplay(Subject weatherData) {
+ public CurrentConditionsDisplay(Subject weatherData)
+ {
weatherData.resisterObserver(this);
}
@Override
- public void update(float temp, float humidity, float pressure) {
+ public void update(float temp, float humidity, float pressure)
+ {
System.out.println("CurrentConditionsDisplay.update: " + temp + " " + humidity + " " + pressure);
}
}
\ No newline at end of file
diff --git a/Observer/src/Observer.java b/Observer/src/Observer.java
index a487048..120cebe 100644
--- a/Observer/src/Observer.java
+++ b/Observer/src/Observer.java
@@ -1,3 +1,4 @@
-public interface Observer {
+public interface Observer
+{
void update(float temp, float humidity, float pressure);
}
\ No newline at end of file
diff --git a/Observer/src/StatisticsDisplay.java b/Observer/src/StatisticsDisplay.java
index 7c4181c..a870c95 100644
--- a/Observer/src/StatisticsDisplay.java
+++ b/Observer/src/StatisticsDisplay.java
@@ -1,11 +1,14 @@
-public class StatisticsDisplay implements Observer {
+public class StatisticsDisplay implements Observer
+{
- public StatisticsDisplay(Subject weatherData) {
+ public StatisticsDisplay(Subject weatherData)
+ {
weatherData.resisterObserver(this);
}
@Override
- public void update(float temp, float humidity, float pressure) {
+ public void update(float temp, float humidity, float pressure)
+ {
System.out.println("StatisticsDisplay.update: " + temp + " " + humidity + " " + pressure);
}
}
\ No newline at end of file
diff --git a/Observer/src/Subject.java b/Observer/src/Subject.java
index 2a56f9f..c29d447 100644
--- a/Observer/src/Subject.java
+++ b/Observer/src/Subject.java
@@ -1,4 +1,5 @@
-public interface Subject {
+public interface Subject
+{
void resisterObserver(Observer o);
void removeObserver(Observer o);
diff --git a/Observer/src/WeatherData.java b/Observer/src/WeatherData.java
index 556dae1..486d375 100644
--- a/Observer/src/WeatherData.java
+++ b/Observer/src/WeatherData.java
@@ -1,17 +1,20 @@
import java.util.ArrayList;
import java.util.List;
-public class WeatherData implements Subject {
+public class WeatherData implements Subject
+{
private List observers;
private float temperature;
private float humidity;
private float pressure;
- public WeatherData() {
+ public WeatherData()
+ {
observers = new ArrayList<>();
}
- public void setMeasurements(float temperature, float humidity, float pressure) {
+ public void setMeasurements(float temperature, float humidity, float pressure)
+ {
this.temperature = temperature;
this.humidity = humidity;
this.pressure = pressure;
@@ -19,12 +22,14 @@ public void setMeasurements(float temperature, float humidity, float pressure) {
}
@Override
- public void resisterObserver(Observer o) {
+ public void resisterObserver(Observer o)
+ {
observers.add(o);
}
@Override
- public void removeObserver(Observer o) {
+ public void removeObserver(Observer o)
+ {
int i = observers.indexOf(o);
if (i >= 0) {
observers.remove(i);
@@ -32,7 +37,8 @@ public void removeObserver(Observer o) {
}
@Override
- public void notifyObserver() {
+ public void notifyObserver()
+ {
for (Observer o : observers) {
o.update(temperature, humidity, pressure);
}
diff --git a/Observer/src/WeatherStation.java b/Observer/src/WeatherStation.java
index 2e48b76..a8cf9c2 100644
--- a/Observer/src/WeatherStation.java
+++ b/Observer/src/WeatherStation.java
@@ -1,5 +1,7 @@
-public class WeatherStation {
- public static void main(String[] args) {
+public class WeatherStation
+{
+ public static void main(String[] args)
+ {
WeatherData weatherData = new WeatherData();
CurrentConditionsDisplay currentConditionsDisplay = new CurrentConditionsDisplay(weatherData);
StatisticsDisplay statisticsDisplay = new StatisticsDisplay(weatherData);
diff --git a/Prototype/src/Client.java b/Prototype/src/Client.java
index 7474cf6..7cf4ad8 100644
--- a/Prototype/src/Client.java
+++ b/Prototype/src/Client.java
@@ -1,5 +1,7 @@
-public class Client {
- public static void main(String[] args) {
+public class Client
+{
+ public static void main(String[] args)
+ {
Prototype prototype = new ConcretePrototype("abc");
Prototype clone = prototype.myClone();
System.out.println(clone.toString());
diff --git a/Prototype/src/ConcretePrototype.java b/Prototype/src/ConcretePrototype.java
index 2190355..7d96a40 100644
--- a/Prototype/src/ConcretePrototype.java
+++ b/Prototype/src/ConcretePrototype.java
@@ -1,18 +1,22 @@
-public class ConcretePrototype extends Prototype {
+public class ConcretePrototype extends Prototype
+{
private String filed;
- public ConcretePrototype(String filed) {
+ public ConcretePrototype(String filed)
+ {
this.filed = filed;
}
@Override
- Prototype myClone() {
+ Prototype myClone()
+ {
return new ConcretePrototype(filed);
}
@Override
- public String toString() {
+ public String toString()
+ {
return filed;
}
}
diff --git a/Prototype/src/Prototype.java b/Prototype/src/Prototype.java
index 2aac85c..985a052 100644
--- a/Prototype/src/Prototype.java
+++ b/Prototype/src/Prototype.java
@@ -1,3 +1,4 @@
-public abstract class Prototype {
+public abstract class Prototype
+{
abstract Prototype myClone();
}
diff --git a/Proxy/src/HighResolutionImage.java b/Proxy/src/HighResolutionImage.java
index e98fc74..9f7a8ac 100644
--- a/Proxy/src/HighResolutionImage.java
+++ b/Proxy/src/HighResolutionImage.java
@@ -1,35 +1,41 @@
import java.net.URL;
-public class HighResolutionImage implements Image {
+public class HighResolutionImage implements Image
+{
private URL imageURL;
private long startTime;
private int height;
private int width;
- public int getHeight() {
- return height;
- }
-
- public int getWidth() {
- return width;
- }
-
- public HighResolutionImage(URL imageURL) {
+ public HighResolutionImage(URL imageURL)
+ {
this.imageURL = imageURL;
this.startTime = System.currentTimeMillis();
this.width = 600;
this.height = 600;
}
- public boolean isLoad() {
+ public int getHeight()
+ {
+ return height;
+ }
+
+ public int getWidth()
+ {
+ return width;
+ }
+
+ public boolean isLoad()
+ {
// 模拟图片加载,延迟 3s 加载完成
long endTime = System.currentTimeMillis();
return endTime - startTime > 3000;
}
@Override
- public void showImage() {
+ public void showImage()
+ {
System.out.println("Real Image: " + imageURL);
}
}
\ No newline at end of file
diff --git a/Proxy/src/Image.java b/Proxy/src/Image.java
index d561e1f..676246d 100644
--- a/Proxy/src/Image.java
+++ b/Proxy/src/Image.java
@@ -1,3 +1,4 @@
-public interface Image {
+public interface Image
+{
void showImage();
}
\ No newline at end of file
diff --git a/Proxy/src/ImageProxy.java b/Proxy/src/ImageProxy.java
index fcb0783..250eb9b 100644
--- a/Proxy/src/ImageProxy.java
+++ b/Proxy/src/ImageProxy.java
@@ -1,12 +1,15 @@
-public class ImageProxy implements Image {
+public class ImageProxy implements Image
+{
private HighResolutionImage highResolutionImage;
- public ImageProxy(HighResolutionImage highResolutionImage) {
+ public ImageProxy(HighResolutionImage highResolutionImage)
+ {
this.highResolutionImage = highResolutionImage;
}
@Override
- public void showImage() {
+ public void showImage()
+ {
while (!highResolutionImage.isLoad()) {
try {
System.out.println("Temp Image: " + highResolutionImage.getWidth() + " " + highResolutionImage.getHeight());
diff --git a/Proxy/src/ImageViewer.java b/Proxy/src/ImageViewer.java
index 30b0d89..41f879a 100644
--- a/Proxy/src/ImageViewer.java
+++ b/Proxy/src/ImageViewer.java
@@ -1,7 +1,9 @@
import java.net.URL;
-public class ImageViewer {
- public static void main(String[] args) throws Exception {
+public class ImageViewer
+{
+ public static void main(String[] args) throws Exception
+ {
String image = "http://image.jpg";
URL url = new URL(image);
HighResolutionImage highResolutionImage = new HighResolutionImage(url);
diff --git a/SimpleFactory/src/Client.java b/SimpleFactory/src/Client.java
index 8f85fb1..7b3ab39 100644
--- a/SimpleFactory/src/Client.java
+++ b/SimpleFactory/src/Client.java
@@ -1,5 +1,7 @@
-public class Client {
- public static void main(String[] args) {
+public class Client
+{
+ public static void main(String[] args)
+ {
int type = 1;
Product product;
if (type == 1) {
diff --git a/SimpleFactory/src/ConcreteProduct.java b/SimpleFactory/src/ConcreteProduct.java
index aa9f661..4c1d03b 100644
--- a/SimpleFactory/src/ConcreteProduct.java
+++ b/SimpleFactory/src/ConcreteProduct.java
@@ -1,2 +1,3 @@
-public class ConcreteProduct implements Product{
+public class ConcreteProduct implements Product
+{
}
diff --git a/SimpleFactory/src/ConcreteProduct1.java b/SimpleFactory/src/ConcreteProduct1.java
index a1b23c2..8683a80 100644
--- a/SimpleFactory/src/ConcreteProduct1.java
+++ b/SimpleFactory/src/ConcreteProduct1.java
@@ -1,2 +1,3 @@
-public class ConcreteProduct1 implements Product{
+public class ConcreteProduct1 implements Product
+{
}
diff --git a/SimpleFactory/src/ConcreteProduct2.java b/SimpleFactory/src/ConcreteProduct2.java
index d5f2b1d..dc2c3aa 100644
--- a/SimpleFactory/src/ConcreteProduct2.java
+++ b/SimpleFactory/src/ConcreteProduct2.java
@@ -1,2 +1,3 @@
-public class ConcreteProduct2 implements Product{
+public class ConcreteProduct2 implements Product
+{
}
diff --git a/SimpleFactory/src/Product.java b/SimpleFactory/src/Product.java
index 1237950..8ec1a6b 100644
--- a/SimpleFactory/src/Product.java
+++ b/SimpleFactory/src/Product.java
@@ -1,2 +1,3 @@
-public interface Product {
+public interface Product
+{
}
diff --git a/SimpleFactory/src/SimpleFactory.java b/SimpleFactory/src/SimpleFactory.java
index 81d58d9..74e4696 100644
--- a/SimpleFactory/src/SimpleFactory.java
+++ b/SimpleFactory/src/SimpleFactory.java
@@ -1,5 +1,7 @@
-public class SimpleFactory {
- public Product createProduct(int type) {
+public class SimpleFactory
+{
+ public Product createProduct(int type)
+ {
if (type == 1) {
return new ConcreteProduct1();
} else if (type == 2) {
diff --git a/Singleton/src/imp1/Singleton.java b/Singleton/src/imp1/Singleton.java
index 3060c8e..0c9b8f6 100644
--- a/Singleton/src/imp1/Singleton.java
+++ b/Singleton/src/imp1/Singleton.java
@@ -1,12 +1,15 @@
package imp1;
-public class Singleton {
+public class Singleton
+{
private static Singleton uniqueInstance;
- private Singleton() {
+ private Singleton()
+ {
}
- public static Singleton getUniqueInstance() {
+ public static Singleton getUniqueInstance()
+ {
if (uniqueInstance == null) {
uniqueInstance = new Singleton();
}
diff --git a/Singleton/src/imp2/Singleton.java b/Singleton/src/imp2/Singleton.java
index 767e18f..424b5cd 100644
--- a/Singleton/src/imp2/Singleton.java
+++ b/Singleton/src/imp2/Singleton.java
@@ -1,12 +1,15 @@
package imp2;
-public class Singleton {
+public class Singleton
+{
private static Singleton uniqueInstance;
- private Singleton() {
+ private Singleton()
+ {
}
- public static synchronized Singleton getUniqueInstance() {
+ public static synchronized Singleton getUniqueInstance()
+ {
if (uniqueInstance == null) {
uniqueInstance = new Singleton();
}
diff --git a/Singleton/src/imp3/Singleton.java b/Singleton/src/imp3/Singleton.java
index 7bf4b11..c873296 100644
--- a/Singleton/src/imp3/Singleton.java
+++ b/Singleton/src/imp3/Singleton.java
@@ -1,12 +1,15 @@
package imp3;
-public class Singleton {
+public class Singleton
+{
private static Singleton uniqueInstance = new Singleton();
- private Singleton() {
+ private Singleton()
+ {
}
- public static Singleton getUniqueInstance() {
+ public static Singleton getUniqueInstance()
+ {
return uniqueInstance;
}
}
\ No newline at end of file
diff --git a/Singleton/src/imp4/Singleton.java b/Singleton/src/imp4/Singleton.java
index 986652e..453a81d 100644
--- a/Singleton/src/imp4/Singleton.java
+++ b/Singleton/src/imp4/Singleton.java
@@ -1,12 +1,15 @@
package imp4;
-public class Singleton {
+public class Singleton
+{
private volatile static Singleton uniqueInstance;
- private Singleton() {
+ private Singleton()
+ {
}
- public static Singleton getUniqueInstance() {
+ public static Singleton getUniqueInstance()
+ {
if (uniqueInstance == null) {
synchronized (Singleton.class) {
if (uniqueInstance == null) {
diff --git a/Singleton/src/imp5/Singleton.java b/Singleton/src/imp5/Singleton.java
index e0dd84b..f396d50 100644
--- a/Singleton/src/imp5/Singleton.java
+++ b/Singleton/src/imp5/Singleton.java
@@ -1,5 +1,6 @@
package imp5;
-public enum Singleton {
+public enum Singleton
+{
uniqueInstance
}
\ No newline at end of file
diff --git a/State/src/Client.java b/State/src/Client.java
index 5b56328..c1a20df 100644
--- a/State/src/Client.java
+++ b/State/src/Client.java
@@ -1,6 +1,8 @@
-public class Client {
+public class Client
+{
- public static void main(String[] args) {
+ public static void main(String[] args)
+ {
GumballMachine gumballMachine = new GumballMachine(5);
gumballMachine.insertQuarter();
diff --git a/State/src/GumballMachine.java b/State/src/GumballMachine.java
index 1501785..593d036 100644
--- a/State/src/GumballMachine.java
+++ b/State/src/GumballMachine.java
@@ -1,4 +1,5 @@
-public class GumballMachine {
+public class GumballMachine
+{
private State soldOutState;
private State noQuarterState;
@@ -8,7 +9,8 @@ public class GumballMachine {
private State state;
private int count = 0;
- public GumballMachine(int numberGumballs) {
+ public GumballMachine(int numberGumballs)
+ {
count = numberGumballs;
soldOutState = new SoldOutState(this);
noQuarterState = new NoQuarterState(this);
@@ -22,47 +24,57 @@ public GumballMachine(int numberGumballs) {
}
}
- public void insertQuarter() {
+ public void insertQuarter()
+ {
state.insertQuarter();
}
- public void ejectQuarter() {
+ public void ejectQuarter()
+ {
state.ejectQuarter();
}
- public void turnCrank() {
+ public void turnCrank()
+ {
state.turnCrank();
state.dispense();
}
- public void setState(State state) {
+ public void setState(State state)
+ {
this.state = state;
}
- public void releaseBall() {
+ public void releaseBall()
+ {
System.out.println("A gumball comes rolling out the slot...");
if (count != 0) {
count -= 1;
}
}
- public State getSoldOutState() {
+ public State getSoldOutState()
+ {
return soldOutState;
}
- public State getNoQuarterState() {
+ public State getNoQuarterState()
+ {
return noQuarterState;
}
- public State getHasQuarterState() {
+ public State getHasQuarterState()
+ {
return hasQuarterState;
}
- public State getSoldState() {
+ public State getSoldState()
+ {
return soldState;
}
- public int getCount() {
+ public int getCount()
+ {
return count;
}
}
\ No newline at end of file
diff --git a/State/src/HasQuarterState.java b/State/src/HasQuarterState.java
index 306dc8d..5c71dc6 100644
--- a/State/src/HasQuarterState.java
+++ b/State/src/HasQuarterState.java
@@ -1,30 +1,36 @@
-public class HasQuarterState implements State {
+public class HasQuarterState implements State
+{
private GumballMachine gumballMachine;
- public HasQuarterState(GumballMachine gumballMachine) {
+ public HasQuarterState(GumballMachine gumballMachine)
+ {
this.gumballMachine = gumballMachine;
}
@Override
- public void insertQuarter() {
+ public void insertQuarter()
+ {
System.out.println("You can't insert another quarter");
}
@Override
- public void ejectQuarter() {
+ public void ejectQuarter()
+ {
System.out.println("Quarter returned");
gumballMachine.setState(gumballMachine.getNoQuarterState());
}
@Override
- public void turnCrank() {
+ public void turnCrank()
+ {
System.out.println("You turned...");
gumballMachine.setState(gumballMachine.getSoldState());
}
@Override
- public void dispense() {
+ public void dispense()
+ {
System.out.println("No gumball dispensed");
}
}
\ No newline at end of file
diff --git a/State/src/NoQuarterState.java b/State/src/NoQuarterState.java
index 6af70aa..da15776 100644
--- a/State/src/NoQuarterState.java
+++ b/State/src/NoQuarterState.java
@@ -1,29 +1,35 @@
-public class NoQuarterState implements State {
+public class NoQuarterState implements State
+{
GumballMachine gumballMachine;
- public NoQuarterState(GumballMachine gumballMachine) {
+ public NoQuarterState(GumballMachine gumballMachine)
+ {
this.gumballMachine = gumballMachine;
}
@Override
- public void insertQuarter() {
+ public void insertQuarter()
+ {
System.out.println("You insert a quarter");
gumballMachine.setState(gumballMachine.getHasQuarterState());
}
@Override
- public void ejectQuarter() {
+ public void ejectQuarter()
+ {
System.out.println("You haven't insert a quarter");
}
@Override
- public void turnCrank() {
+ public void turnCrank()
+ {
System.out.println("You turned, but there's no quarter");
}
@Override
- public void dispense() {
+ public void dispense()
+ {
System.out.println("You need to pay first");
}
}
\ No newline at end of file
diff --git a/State/src/SoldOutState.java b/State/src/SoldOutState.java
index 9b49c73..44ab3d9 100644
--- a/State/src/SoldOutState.java
+++ b/State/src/SoldOutState.java
@@ -1,28 +1,34 @@
-public class SoldOutState implements State {
+public class SoldOutState implements State
+{
GumballMachine gumballMachine;
- public SoldOutState(GumballMachine gumballMachine) {
+ public SoldOutState(GumballMachine gumballMachine)
+ {
this.gumballMachine = gumballMachine;
}
@Override
- public void insertQuarter() {
+ public void insertQuarter()
+ {
System.out.println("You can't insert a quarter, the machine is sold out");
}
@Override
- public void ejectQuarter() {
+ public void ejectQuarter()
+ {
System.out.println("You can't eject, you haven't inserted a quarter yet");
}
@Override
- public void turnCrank() {
+ public void turnCrank()
+ {
System.out.println("You turned, but there are no gumballs");
}
@Override
- public void dispense() {
+ public void dispense()
+ {
System.out.println("No gumball dispensed");
}
}
\ No newline at end of file
diff --git a/State/src/SoldState.java b/State/src/SoldState.java
index c36c152..50c6cd5 100644
--- a/State/src/SoldState.java
+++ b/State/src/SoldState.java
@@ -1,28 +1,34 @@
-public class SoldState implements State {
+public class SoldState implements State
+{
GumballMachine gumballMachine;
- public SoldState(GumballMachine gumballMachine) {
+ public SoldState(GumballMachine gumballMachine)
+ {
this.gumballMachine = gumballMachine;
}
@Override
- public void insertQuarter() {
+ public void insertQuarter()
+ {
System.out.println("Please wait, we're already giving you a gumball");
}
@Override
- public void ejectQuarter() {
+ public void ejectQuarter()
+ {
System.out.println("Sorry, you already turned the crank");
}
@Override
- public void turnCrank() {
+ public void turnCrank()
+ {
System.out.println("Turning twice doesn't get you another gumball!");
}
@Override
- public void dispense() {
+ public void dispense()
+ {
gumballMachine.releaseBall();
if (gumballMachine.getCount() > 0) {
gumballMachine.setState(gumballMachine.getNoQuarterState());
diff --git a/State/src/State.java b/State/src/State.java
index cfaec11..af0315d 100644
--- a/State/src/State.java
+++ b/State/src/State.java
@@ -1,4 +1,5 @@
-public interface State {
+public interface State
+{
/**
* 投入 25 分钱
*/
diff --git a/Strategy/src/Client.java b/Strategy/src/Client.java
index 490a65f..f9f9ffb 100644
--- a/Strategy/src/Client.java
+++ b/Strategy/src/Client.java
@@ -1,5 +1,7 @@
-public class Client {
- public static void main(String[] args) {
+public class Client
+{
+ public static void main(String[] args)
+ {
Duck duck = new Duck();
duck.setQuackBehavior(new Squeak());
duck.performQuack();
diff --git a/Strategy/src/Duck.java b/Strategy/src/Duck.java
index d68a93c..2839485 100644
--- a/Strategy/src/Duck.java
+++ b/Strategy/src/Duck.java
@@ -1,13 +1,16 @@
-public class Duck {
+public class Duck
+{
private QuackBehavior quackBehavior;
- public void performQuack() {
+ public void performQuack()
+ {
if (quackBehavior != null) {
quackBehavior.quack();
}
}
- public void setQuackBehavior(QuackBehavior quackBehavior) {
+ public void setQuackBehavior(QuackBehavior quackBehavior)
+ {
this.quackBehavior = quackBehavior;
}
}
diff --git a/Strategy/src/Quack.java b/Strategy/src/Quack.java
index 17bc671..3de8c7b 100644
--- a/Strategy/src/Quack.java
+++ b/Strategy/src/Quack.java
@@ -1,6 +1,8 @@
-public class Quack implements QuackBehavior {
+public class Quack implements QuackBehavior
+{
@Override
- public void quack() {
+ public void quack()
+ {
System.out.println("quack!");
}
}
diff --git a/Strategy/src/QuackBehavior.java b/Strategy/src/QuackBehavior.java
index ec36007..4401042 100644
--- a/Strategy/src/QuackBehavior.java
+++ b/Strategy/src/QuackBehavior.java
@@ -1,3 +1,4 @@
-public interface QuackBehavior {
+public interface QuackBehavior
+{
void quack();
}
diff --git a/Strategy/src/Squeak.java b/Strategy/src/Squeak.java
index 5880d52..bcbd801 100644
--- a/Strategy/src/Squeak.java
+++ b/Strategy/src/Squeak.java
@@ -1,6 +1,8 @@
-public class Squeak implements QuackBehavior{
+public class Squeak implements QuackBehavior
+{
@Override
- public void quack() {
+ public void quack()
+ {
System.out.println("squeak!");
}
}
diff --git a/TemplateMethod/src/CaffeineBeverage.java b/TemplateMethod/src/CaffeineBeverage.java
index d23dccd..9ac589a 100644
--- a/TemplateMethod/src/CaffeineBeverage.java
+++ b/TemplateMethod/src/CaffeineBeverage.java
@@ -1,6 +1,8 @@
-public abstract class CaffeineBeverage {
+public abstract class CaffeineBeverage
+{
- final void prepareRecipe() {
+ final void prepareRecipe()
+ {
boilWater();
brew();
pourInCup();
@@ -11,11 +13,13 @@ final void prepareRecipe() {
abstract void addCondiments();
- void boilWater() {
+ void boilWater()
+ {
System.out.println("boilWater");
}
- void pourInCup() {
+ void pourInCup()
+ {
System.out.println("pourInCup");
}
}
\ No newline at end of file
diff --git a/TemplateMethod/src/Client.java b/TemplateMethod/src/Client.java
index fbf3944..9584dab 100644
--- a/TemplateMethod/src/Client.java
+++ b/TemplateMethod/src/Client.java
@@ -1,5 +1,7 @@
-public class Client {
- public static void main(String[] args) {
+public class Client
+{
+ public static void main(String[] args)
+ {
CaffeineBeverage caffeineBeverage = new Coffee();
caffeineBeverage.prepareRecipe();
System.out.println("-----------");
diff --git a/TemplateMethod/src/Coffee.java b/TemplateMethod/src/Coffee.java
index 210006e..3e9db76 100644
--- a/TemplateMethod/src/Coffee.java
+++ b/TemplateMethod/src/Coffee.java
@@ -1,11 +1,14 @@
-public class Coffee extends CaffeineBeverage{
+public class Coffee extends CaffeineBeverage
+{
@Override
- void brew() {
+ void brew()
+ {
System.out.println("Coffee.brew");
}
@Override
- void addCondiments() {
+ void addCondiments()
+ {
System.out.println("Coffee.addCondiments");
}
}
\ No newline at end of file
diff --git a/TemplateMethod/src/Tea.java b/TemplateMethod/src/Tea.java
index 757ae0c..a52d3c6 100644
--- a/TemplateMethod/src/Tea.java
+++ b/TemplateMethod/src/Tea.java
@@ -1,11 +1,14 @@
-public class Tea extends CaffeineBeverage{
+public class Tea extends CaffeineBeverage
+{
@Override
- void brew() {
+ void brew()
+ {
System.out.println("Tea.brew");
}
@Override
- void addCondiments() {
+ void addCondiments()
+ {
System.out.println("Tea.addCondiments");
}
}
\ No newline at end of file
diff --git a/Visitor/src/Client.java b/Visitor/src/Client.java
index 9325bc4..4fcd88b 100644
--- a/Visitor/src/Client.java
+++ b/Visitor/src/Client.java
@@ -1,5 +1,7 @@
-public class Client {
- public static void main(String[] args) {
+public class Client
+{
+ public static void main(String[] args)
+ {
Customer customer1 = new Customer("customer1");
customer1.addOrder(new Order("order1", "item1"));
customer1.addOrder(new Order("order2", "item1"));
diff --git a/Visitor/src/Customer.java b/Visitor/src/Customer.java
index d8f7f0f..457bc39 100644
--- a/Visitor/src/Customer.java
+++ b/Visitor/src/Customer.java
@@ -1,24 +1,29 @@
import java.util.ArrayList;
import java.util.List;
-public class Customer implements Element {
+public class Customer implements Element
+{
private String name;
private List orders = new ArrayList<>();
- Customer(String name) {
+ Customer(String name)
+ {
this.name = name;
}
- String getName() {
+ String getName()
+ {
return name;
}
- void addOrder(Order order) {
+ void addOrder(Order order)
+ {
orders.add(order);
}
- public void accept(Visitor visitor) {
+ public void accept(Visitor visitor)
+ {
visitor.visit(this);
for (Order order : orders) {
order.accept(visitor);
diff --git a/Visitor/src/CustomerGroup.java b/Visitor/src/CustomerGroup.java
index e65174f..c5b1e14 100644
--- a/Visitor/src/CustomerGroup.java
+++ b/Visitor/src/CustomerGroup.java
@@ -1,17 +1,20 @@
import java.util.ArrayList;
import java.util.List;
-class CustomerGroup {
+class CustomerGroup
+{
private List customers = new ArrayList<>();
- void accept(Visitor visitor) {
+ void accept(Visitor visitor)
+ {
for (Customer customer : customers) {
customer.accept(visitor);
}
}
- void addCustomer(Customer customer) {
+ void addCustomer(Customer customer)
+ {
customers.add(customer);
}
}
\ No newline at end of file
diff --git a/Visitor/src/Element.java b/Visitor/src/Element.java
index 15f6d02..ecf67f1 100644
--- a/Visitor/src/Element.java
+++ b/Visitor/src/Element.java
@@ -1,3 +1,4 @@
-public interface Element {
- void accept(Visitor visitor);
+public interface Element
+{
+ void accept(Visitor visitor);
}
\ No newline at end of file
diff --git a/Visitor/src/GeneralReport.java b/Visitor/src/GeneralReport.java
index 613a128..fac7acd 100644
--- a/Visitor/src/GeneralReport.java
+++ b/Visitor/src/GeneralReport.java
@@ -1,25 +1,30 @@
-public class GeneralReport implements Visitor {
+public class GeneralReport implements Visitor
+{
private int customersNo;
private int ordersNo;
private int itemsNo;
- public void visit(Customer customer) {
+ public void visit(Customer customer)
+ {
System.out.println(customer.getName());
customersNo++;
}
- public void visit(Order order) {
+ public void visit(Order order)
+ {
System.out.println(order.getName());
ordersNo++;
}
- public void visit(Item item) {
+ public void visit(Item item)
+ {
System.out.println(item.getName());
itemsNo++;
}
- public void displayResults() {
+ public void displayResults()
+ {
System.out.println("Number of customers: " + customersNo);
System.out.println("Number of orders: " + ordersNo);
System.out.println("Number of items: " + itemsNo);
diff --git a/Visitor/src/Item.java b/Visitor/src/Item.java
index a10e82a..ffe4a1e 100644
--- a/Visitor/src/Item.java
+++ b/Visitor/src/Item.java
@@ -1,16 +1,20 @@
-public class Item implements Element {
+public class Item implements Element
+{
private String name;
- Item(String name) {
+ Item(String name)
+ {
this.name = name;
}
- String getName() {
+ String getName()
+ {
return name;
}
- public void accept(Visitor visitor) {
+ public void accept(Visitor visitor)
+ {
visitor.visit(this);
}
}
\ No newline at end of file
diff --git a/Visitor/src/Order.java b/Visitor/src/Order.java
index fb5efc6..be0a513 100644
--- a/Visitor/src/Order.java
+++ b/Visitor/src/Order.java
@@ -1,29 +1,35 @@
import java.util.ArrayList;
import java.util.List;
-public class Order implements Element {
+public class Order implements Element
+{
private String name;
private List- items = new ArrayList();
- Order(String name) {
+ Order(String name)
+ {
this.name = name;
}
- Order(String name, String itemName) {
+ Order(String name, String itemName)
+ {
this.name = name;
this.addItem(new Item(itemName));
}
- String getName() {
+ String getName()
+ {
return name;
}
- void addItem(Item item) {
+ void addItem(Item item)
+ {
items.add(item);
}
- public void accept(Visitor visitor) {
+ public void accept(Visitor visitor)
+ {
visitor.visit(this);
for (Item item : items) {
diff --git a/Visitor/src/Visitor.java b/Visitor/src/Visitor.java
index ee71832..7504b4e 100644
--- a/Visitor/src/Visitor.java
+++ b/Visitor/src/Visitor.java
@@ -1,4 +1,5 @@
-public interface Visitor {
+public interface Visitor
+{
void visit(Customer customer);
void visit(Order order);
From 2b5364af9e9b4060c3a5e5034d4d0a0762eb3e8a Mon Sep 17 00:00:00 2001
From: CyC2018 <1029579233@qq.com>
Date: Fri, 29 Jun 2018 22:50:15 +0800
Subject: [PATCH 14/16] update .gitignore
---
.idea/encodings.xml | 6 ----
.idea/misc.xml | 6 ----
.idea/modules.xml | 33 -------------------
.idea/vcs.xml | 6 ----
AbstractFactory/AbstractFactory.iml | 11 -------
Adapter/Adapter.iml | 11 -------
Bridge/Bridge.iml | 11 -------
Builder/Builder.iml | 11 -------
.../ChainOfResponsibility.iml | 11 -------
Command/Command.iml | 11 -------
Composite/Composite.iml | 11 -------
Decorator/Decorator.iml | 11 -------
Facade/Facade.iml | 11 -------
FactoryMethod/FactoryMethod.iml | 11 -------
Flyweight/Flyweight.iml | 11 -------
Interpreter/Interpreter.iml | 11 -------
Iterator/Iterator.iml | 11 -------
Mediator/Mediator.iml | 11 -------
Menento/Menento.iml | 11 -------
Null/Null.iml | 11 -------
Observer/Observer.iml | 11 -------
Prototype/Prototype.iml | 11 -------
Proxy/Proxy.iml | 11 -------
SimpleFactory/SimpleFactory.iml | 11 -------
Singleton/Singleton.iml | 11 -------
State/State.iml | 11 -------
Strategy/Strategy.iml | 11 -------
TemplateMethod/TemplateMethod.iml | 11 -------
Visitor/Visitor.iml | 11 -------
...6\350\256\241\346\250\241\345\274\217.iml" | 11 -------
30 files changed, 337 deletions(-)
delete mode 100644 .idea/encodings.xml
delete mode 100644 .idea/misc.xml
delete mode 100644 .idea/modules.xml
delete mode 100644 .idea/vcs.xml
delete mode 100644 AbstractFactory/AbstractFactory.iml
delete mode 100644 Adapter/Adapter.iml
delete mode 100644 Bridge/Bridge.iml
delete mode 100644 Builder/Builder.iml
delete mode 100644 ChainOfResponsibility/ChainOfResponsibility.iml
delete mode 100644 Command/Command.iml
delete mode 100644 Composite/Composite.iml
delete mode 100644 Decorator/Decorator.iml
delete mode 100644 Facade/Facade.iml
delete mode 100644 FactoryMethod/FactoryMethod.iml
delete mode 100644 Flyweight/Flyweight.iml
delete mode 100644 Interpreter/Interpreter.iml
delete mode 100644 Iterator/Iterator.iml
delete mode 100644 Mediator/Mediator.iml
delete mode 100644 Menento/Menento.iml
delete mode 100644 Null/Null.iml
delete mode 100644 Observer/Observer.iml
delete mode 100644 Prototype/Prototype.iml
delete mode 100644 Proxy/Proxy.iml
delete mode 100644 SimpleFactory/SimpleFactory.iml
delete mode 100644 Singleton/Singleton.iml
delete mode 100644 State/State.iml
delete mode 100644 Strategy/Strategy.iml
delete mode 100644 TemplateMethod/TemplateMethod.iml
delete mode 100644 Visitor/Visitor.iml
delete mode 100644 "\350\256\276\350\256\241\346\250\241\345\274\217.iml"
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index 97626ba..0000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 0548357..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 2ac71e3..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/AbstractFactory/AbstractFactory.iml b/AbstractFactory/AbstractFactory.iml
deleted file mode 100644
index c90834f..0000000
--- a/AbstractFactory/AbstractFactory.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Adapter/Adapter.iml b/Adapter/Adapter.iml
deleted file mode 100644
index c90834f..0000000
--- a/Adapter/Adapter.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Bridge/Bridge.iml b/Bridge/Bridge.iml
deleted file mode 100644
index c90834f..0000000
--- a/Bridge/Bridge.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Builder/Builder.iml b/Builder/Builder.iml
deleted file mode 100644
index c90834f..0000000
--- a/Builder/Builder.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ChainOfResponsibility/ChainOfResponsibility.iml b/ChainOfResponsibility/ChainOfResponsibility.iml
deleted file mode 100644
index c90834f..0000000
--- a/ChainOfResponsibility/ChainOfResponsibility.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Command/Command.iml b/Command/Command.iml
deleted file mode 100644
index c90834f..0000000
--- a/Command/Command.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Composite/Composite.iml b/Composite/Composite.iml
deleted file mode 100644
index c90834f..0000000
--- a/Composite/Composite.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Decorator/Decorator.iml b/Decorator/Decorator.iml
deleted file mode 100644
index c90834f..0000000
--- a/Decorator/Decorator.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Facade/Facade.iml b/Facade/Facade.iml
deleted file mode 100644
index c90834f..0000000
--- a/Facade/Facade.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/FactoryMethod/FactoryMethod.iml b/FactoryMethod/FactoryMethod.iml
deleted file mode 100644
index c90834f..0000000
--- a/FactoryMethod/FactoryMethod.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Flyweight/Flyweight.iml b/Flyweight/Flyweight.iml
deleted file mode 100644
index c90834f..0000000
--- a/Flyweight/Flyweight.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Interpreter/Interpreter.iml b/Interpreter/Interpreter.iml
deleted file mode 100644
index c90834f..0000000
--- a/Interpreter/Interpreter.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Iterator/Iterator.iml b/Iterator/Iterator.iml
deleted file mode 100644
index c90834f..0000000
--- a/Iterator/Iterator.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Mediator/Mediator.iml b/Mediator/Mediator.iml
deleted file mode 100644
index c90834f..0000000
--- a/Mediator/Mediator.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Menento/Menento.iml b/Menento/Menento.iml
deleted file mode 100644
index c90834f..0000000
--- a/Menento/Menento.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Null/Null.iml b/Null/Null.iml
deleted file mode 100644
index c90834f..0000000
--- a/Null/Null.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Observer/Observer.iml b/Observer/Observer.iml
deleted file mode 100644
index c90834f..0000000
--- a/Observer/Observer.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Prototype/Prototype.iml b/Prototype/Prototype.iml
deleted file mode 100644
index c90834f..0000000
--- a/Prototype/Prototype.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Proxy/Proxy.iml b/Proxy/Proxy.iml
deleted file mode 100644
index c90834f..0000000
--- a/Proxy/Proxy.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/SimpleFactory/SimpleFactory.iml b/SimpleFactory/SimpleFactory.iml
deleted file mode 100644
index c90834f..0000000
--- a/SimpleFactory/SimpleFactory.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Singleton/Singleton.iml b/Singleton/Singleton.iml
deleted file mode 100644
index c90834f..0000000
--- a/Singleton/Singleton.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/State/State.iml b/State/State.iml
deleted file mode 100644
index c90834f..0000000
--- a/State/State.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Strategy/Strategy.iml b/Strategy/Strategy.iml
deleted file mode 100644
index c90834f..0000000
--- a/Strategy/Strategy.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/TemplateMethod/TemplateMethod.iml b/TemplateMethod/TemplateMethod.iml
deleted file mode 100644
index c90834f..0000000
--- a/TemplateMethod/TemplateMethod.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Visitor/Visitor.iml b/Visitor/Visitor.iml
deleted file mode 100644
index c90834f..0000000
--- a/Visitor/Visitor.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git "a/\350\256\276\350\256\241\346\250\241\345\274\217.iml" "b/\350\256\276\350\256\241\346\250\241\345\274\217.iml"
deleted file mode 100644
index c90834f..0000000
--- "a/\350\256\276\350\256\241\346\250\241\345\274\217.iml"
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
From e97ac33496bc259664945a004cd950755e627ea2 Mon Sep 17 00:00:00 2001
From: CyC2018 <1029579233@qq.com>
Date: Sat, 30 Jun 2018 13:06:06 +0800
Subject: [PATCH 15/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E7=8A=B6?=
=?UTF-8?q?=E6=80=81=E6=A8=A1=E5=BC=8F=E5=92=8C=E7=AD=96=E7=95=A5=E6=A8=A1?=
=?UTF-8?q?=E5=BC=8F=E7=9A=84=E7=B1=BB=E5=9B=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Observer/src/CurrentConditionsDisplay.java | 1 -
Observer/src/StatisticsDisplay.java | 1 -
.../\347\255\226\347\225\245.mdj" | 87 ++++++++++++++-----
.../\350\247\202\345\257\237\350\200\205.mdj" | 30 +++----
4 files changed, 81 insertions(+), 38 deletions(-)
diff --git a/Observer/src/CurrentConditionsDisplay.java b/Observer/src/CurrentConditionsDisplay.java
index dd13dc1..13b4851 100644
--- a/Observer/src/CurrentConditionsDisplay.java
+++ b/Observer/src/CurrentConditionsDisplay.java
@@ -1,6 +1,5 @@
public class CurrentConditionsDisplay implements Observer
{
-
public CurrentConditionsDisplay(Subject weatherData)
{
weatherData.resisterObserver(this);
diff --git a/Observer/src/StatisticsDisplay.java b/Observer/src/StatisticsDisplay.java
index a870c95..0dba7d2 100644
--- a/Observer/src/StatisticsDisplay.java
+++ b/Observer/src/StatisticsDisplay.java
@@ -1,6 +1,5 @@
public class StatisticsDisplay implements Observer
{
-
public StatisticsDisplay(Subject weatherData)
{
weatherData.resisterObserver(this);
diff --git "a/UML \347\273\230\345\233\276/\347\255\226\347\225\245.mdj" "b/UML \347\273\230\345\233\276/\347\255\226\347\225\245.mdj"
index 25f33e4..723befa 100644
--- "a/UML \347\273\230\345\233\276/\347\255\226\347\225\245.mdj"
+++ "b/UML \347\273\230\345\233\276/\347\255\226\347\225\245.mdj"
@@ -364,13 +364,30 @@
"height": 13,
"text": "+doSomething(): void",
"horizontalAlignment": 0
+ },
+ {
+ "_type": "UMLOperationView",
+ "_id": "AAAAAAFkTw+KyaIntFc=",
+ "_parent": {
+ "$ref": "AAAAAAFjyf9WQjR6zOY="
+ },
+ "model": {
+ "$ref": "AAAAAAFkTw+Kr6IkS/8="
+ },
+ "font": "Arial;13;0",
+ "left": 213,
+ "top": 372,
+ "width": 161.49072265625,
+ "height": 13,
+ "text": "+setStrategy(Strategy): void",
+ "horizontalAlignment": 0
}
],
"font": "Arial;13;0",
"left": 208,
"top": 352,
"width": 171.49072265625,
- "height": 23
+ "height": 38
},
{
"_type": "UMLReceptionCompartmentView",
@@ -410,7 +427,7 @@
"left": 208,
"top": 304,
"width": 171.49072265625,
- "height": 73,
+ "height": 86,
"nameCompartment": {
"$ref": "AAAAAAFjyf9WQjR0HB0="
},
@@ -1026,8 +1043,8 @@
},
"visible": false,
"font": "Arial;13;0",
- "left": 412,
- "top": 350,
+ "left": 413,
+ "top": 352,
"height": 13,
"alpha": 1.5707963267948966,
"distance": 15,
@@ -1047,8 +1064,8 @@
},
"visible": null,
"font": "Arial;13;0",
- "left": 412,
- "top": 365,
+ "left": 413,
+ "top": 367,
"height": 13,
"alpha": 1.5707963267948966,
"distance": 30,
@@ -1068,8 +1085,8 @@
},
"visible": false,
"font": "Arial;13;0",
- "left": 413,
- "top": 320,
+ "left": 412,
+ "top": 323,
"height": 13,
"alpha": -1.5707963267948966,
"distance": 15,
@@ -1090,7 +1107,7 @@
"visible": false,
"font": "Arial;13;0",
"left": 421,
- "top": 349,
+ "top": 352,
"height": 13,
"alpha": 0.5235987755982988,
"distance": 30,
@@ -1110,8 +1127,8 @@
},
"visible": false,
"font": "Arial;13;0",
- "left": 418,
- "top": 363,
+ "left": 419,
+ "top": 366,
"height": 13,
"alpha": 0.7853981633974483,
"distance": 40,
@@ -1131,8 +1148,8 @@
},
"visible": false,
"font": "Arial;13;0",
- "left": 425,
- "top": 322,
+ "left": 424,
+ "top": 325,
"height": 13,
"alpha": -0.5235987755982988,
"distance": 25,
@@ -1152,8 +1169,8 @@
},
"visible": false,
"font": "Arial;13;0",
- "left": 404,
- "top": 349,
+ "left": 405,
+ "top": 353,
"height": 13,
"alpha": -0.5235987755982988,
"distance": 30,
@@ -1172,8 +1189,8 @@
},
"visible": false,
"font": "Arial;13;0",
- "left": 407,
- "top": 363,
+ "left": 408,
+ "top": 366,
"height": 13,
"alpha": -0.7853981633974483,
"distance": 40,
@@ -1193,7 +1210,7 @@
"visible": false,
"font": "Arial;13;0",
"left": 400,
- "top": 322,
+ "top": 325,
"height": 13,
"alpha": 0.5235987755982988,
"distance": 25,
@@ -1238,7 +1255,7 @@
"$ref": "AAAAAAFjyff0zjQ/wz8="
},
"lineStyle": 1,
- "points": "447:341;379:341",
+ "points": "447:343;379:345",
"showVisibility": true,
"nameLabel": {
"$ref": "AAAAAAFjygEsyTWn0Lc="
@@ -1301,7 +1318,7 @@
"$ref": "AAAAAAFjyzJwxTn0hUs="
},
"lineStyle": 1,
- "points": "214:415;254:377"
+ "points": "215:415;244:390"
}
]
},
@@ -1346,7 +1363,7 @@
"reference": {
"$ref": "AAAAAAFjyf9WQjRxbjU="
},
- "aggregation": "composite"
+ "aggregation": "shared"
}
}
],
@@ -1411,6 +1428,34 @@
"direction": "return"
}
]
+ },
+ {
+ "_type": "UMLOperation",
+ "_id": "AAAAAAFkTw+Kr6IkS/8=",
+ "_parent": {
+ "$ref": "AAAAAAFjyf9WQjRxbjU="
+ },
+ "name": "setStrategy",
+ "parameters": [
+ {
+ "_type": "UMLParameter",
+ "_id": "AAAAAAFkTw/sX6I6new=",
+ "_parent": {
+ "$ref": "AAAAAAFkTw+Kr6IkS/8="
+ },
+ "name": "Strategy",
+ "type": ""
+ },
+ {
+ "_type": "UMLParameter",
+ "_id": "AAAAAAFkTw/sX6I7JO8=",
+ "_parent": {
+ "$ref": "AAAAAAFkTw+Kr6IkS/8="
+ },
+ "type": "void",
+ "direction": "return"
+ }
+ ]
}
]
},
diff --git "a/UML \347\273\230\345\233\276/\350\247\202\345\257\237\350\200\205.mdj" "b/UML \347\273\230\345\233\276/\350\247\202\345\257\237\350\200\205.mdj"
index 4365163..799cf6e 100644
--- "a/UML \347\273\230\345\233\276/\350\247\202\345\257\237\350\200\205.mdj"
+++ "b/UML \347\273\230\345\233\276/\350\247\202\345\257\237\350\200\205.mdj"
@@ -720,9 +720,9 @@
"font": "Arial;13;1",
"left": 509,
"top": 327,
- "width": 106.208984375,
+ "width": 113.43896484375,
"height": 13,
- "text": "ConreteObserver"
+ "text": "ConcreteObserver"
},
{
"_type": "LabelView",
@@ -755,7 +755,7 @@
"font": "Arial;13;0",
"left": 504,
"top": 320,
- "width": 116.208984375,
+ "width": 123.43896484375,
"height": 25,
"stereotypeLabel": {
"$ref": "AAAAAAFjypqAXpGNBSE="
@@ -782,7 +782,7 @@
"font": "Arial;13;0",
"left": 504,
"top": 345,
- "width": 116.208984375,
+ "width": 123.43896484375,
"height": 10
},
{
@@ -807,7 +807,7 @@
"font": "Arial;13;0",
"left": 509,
"top": 360,
- "width": 106.208984375,
+ "width": 113.43896484375,
"height": 13,
"text": "+update(): void",
"horizontalAlignment": 0
@@ -816,7 +816,7 @@
"font": "Arial;13;0",
"left": 504,
"top": 355,
- "width": 116.208984375,
+ "width": 123.43896484375,
"height": 23
},
{
@@ -856,7 +856,7 @@
"containerChangeable": true,
"left": 504,
"top": 320,
- "width": 116.208984375,
+ "width": 123.43896484375,
"height": 58,
"nameCompartment": {
"$ref": "AAAAAAFjypqAXpGMYD4="
@@ -989,8 +989,8 @@
},
"visible": false,
"font": "Arial;13;0",
- "left": 545,
- "top": 263,
+ "left": 547,
+ "top": 264,
"height": 13,
"alpha": 1.5707963267948966,
"distance": 15,
@@ -1010,8 +1010,8 @@
},
"visible": null,
"font": "Arial;13;0",
- "left": 530,
- "top": 263,
+ "left": 532,
+ "top": 264,
"height": 13,
"alpha": 1.5707963267948966,
"distance": 30,
@@ -1031,8 +1031,8 @@
},
"visible": false,
"font": "Arial;13;0",
- "left": 574,
- "top": 264,
+ "left": 576,
+ "top": 263,
"height": 13,
"alpha": -1.5707963267948966,
"distance": 15,
@@ -1050,7 +1050,7 @@
"$ref": "AAAAAAFjypqAXpGLSsk="
},
"lineStyle": 1,
- "points": "561:319;560:221",
+ "points": "564:319;561:221",
"showVisibility": true,
"nameLabel": {
"$ref": "AAAAAAFjyprylpHQ7N8="
@@ -2063,7 +2063,7 @@
"_parent": {
"$ref": "AAAAAAFF+qBWK6M3Z8Y="
},
- "name": "ConreteObserver",
+ "name": "ConcreteObserver",
"ownedElements": [
{
"_type": "UMLInterfaceRealization",
From 979c7004671e0838545bd0bed572ff7d0597aa18 Mon Sep 17 00:00:00 2001
From: CyC2018 <1029579233@qq.com>
Date: Sat, 30 Jun 2018 13:06:58 +0800
Subject: [PATCH 16/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E7=8A=B6?=
=?UTF-8?q?=E6=80=81=E6=A8=A1=E5=BC=8F=E5=92=8C=E7=AD=96=E7=95=A5=E6=A8=A1?=
=?UTF-8?q?=E5=BC=8F=E7=9A=84=E7=B1=BB=E5=9B=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"UML \347\273\230\345\233\276/\347\212\266\346\200\201.mdj" | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git "a/UML \347\273\230\345\233\276/\347\212\266\346\200\201.mdj" "b/UML \347\273\230\345\233\276/\347\212\266\346\200\201.mdj"
index 0c5c3c1..3a9a15f 100644
--- "a/UML \347\273\230\345\233\276/\347\212\266\346\200\201.mdj"
+++ "b/UML \347\273\230\345\233\276/\347\212\266\346\200\201.mdj"
@@ -2232,7 +2232,8 @@
"_parent": {
"$ref": "AAAAAAFjyy2Vqi50TJg="
},
- "name": "state"
+ "name": "state",
+ "type": ""
}
],
"operations": [
@@ -2298,7 +2299,7 @@
"reference": {
"$ref": "AAAAAAFjyy2Vqi50TJg="
},
- "aggregation": "composite"
+ "aggregation": "shared"
}
}
],