修复了注册和登录时的验证码异常
This commit is contained in:
parent
8e3ee826a2
commit
10367bb32c
|
@ -0,0 +1,20 @@
|
||||||
|
package com.greenorange.promotion.designModel;
|
||||||
|
|
||||||
|
public class Client {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
TestController testController = new TestController();
|
||||||
|
|
||||||
|
Light light = new Light();
|
||||||
|
TV tv = new TV();
|
||||||
|
|
||||||
|
LightOnCommand lightOnCommand = new LightOnCommand(light);
|
||||||
|
TVOnCommand tvOnCommand = new TVOnCommand(tv);
|
||||||
|
|
||||||
|
testController.setCommand(lightOnCommand);
|
||||||
|
testController.setCommand(tvOnCommand);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.greenorange.promotion.designModel;
|
||||||
|
|
||||||
|
public interface Command {
|
||||||
|
|
||||||
|
void execute();
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.greenorange.promotion.designModel;
|
||||||
|
|
||||||
|
public class Controller {
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.greenorange.promotion.designModel;
|
||||||
|
|
||||||
|
public class Light {
|
||||||
|
|
||||||
|
public void turnOn() {
|
||||||
|
System.out.println("灯已打开");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.greenorange.promotion.designModel;
|
||||||
|
|
||||||
|
public class LightOnCommand implements Command{
|
||||||
|
|
||||||
|
private Light light;
|
||||||
|
|
||||||
|
public LightOnCommand(Light light) {
|
||||||
|
this.light = light;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
light.turnOn();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.greenorange.promotion.designModel;
|
||||||
|
|
||||||
|
public class TV {
|
||||||
|
|
||||||
|
public void turnOn() {
|
||||||
|
System.out.println("电视已打开");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.greenorange.promotion.designModel;
|
||||||
|
|
||||||
|
public class TVOnCommand implements Command{
|
||||||
|
|
||||||
|
private TV tv;
|
||||||
|
|
||||||
|
public TVOnCommand(TV tv) {
|
||||||
|
this.tv = tv;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
tv.turnOn();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.greenorange.promotion.designModel;
|
||||||
|
|
||||||
|
public class TestController {
|
||||||
|
|
||||||
|
private Command command;
|
||||||
|
|
||||||
|
public void setCommand(Command command) {
|
||||||
|
this.command = command;
|
||||||
|
command.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.greenorange.promotion.factory;
|
||||||
|
|
||||||
|
public interface Computer {
|
||||||
|
|
||||||
|
void turnOn();
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.greenorange.promotion.factory;
|
||||||
|
|
||||||
|
public abstract class ComputerFactory {
|
||||||
|
|
||||||
|
public abstract Computer createComputer();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.greenorange.promotion.factory;
|
||||||
|
|
||||||
|
public class DellComputer implements Computer{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void turnOn() {
|
||||||
|
System.out.println("戴尔电脑开机");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.greenorange.promotion.factory;
|
||||||
|
|
||||||
|
public class DellFactory extends ComputerFactory{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Computer createComputer() {
|
||||||
|
return new DellComputer();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.greenorange.promotion.factory;
|
||||||
|
|
||||||
|
public class LenovoComputer implements Computer{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void turnOn() {
|
||||||
|
System.out.println("联想电脑开机");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.greenorange.promotion.factory;
|
||||||
|
|
||||||
|
public class LenovoFactory extends ComputerFactory {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Computer createComputer() {
|
||||||
|
return new LenovoComputer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.greenorange.promotion.factory;
|
||||||
|
|
||||||
|
public class TestFactory {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
DellFactory dellFactory = new DellFactory();
|
||||||
|
LenovoFactory lenovoFactory = new LenovoFactory();
|
||||||
|
|
||||||
|
Computer dellComputer = dellFactory.createComputer();
|
||||||
|
Computer lenovoComputer = lenovoFactory.createComputer();
|
||||||
|
dellComputer.turnOn();
|
||||||
|
lenovoComputer.turnOn();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user