修复了注册和登录时的验证码异常

This commit is contained in:
chen-xin-zhi 2025-05-21 17:05:00 +08:00
parent 8e3ee826a2
commit 10367bb32c
15 changed files with 157 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -0,0 +1,6 @@
package com.greenorange.promotion.designModel;
public interface Command {
void execute();
}

View File

@ -0,0 +1,4 @@
package com.greenorange.promotion.designModel;
public class Controller {
}

View File

@ -0,0 +1,8 @@
package com.greenorange.promotion.designModel;
public class Light {
public void turnOn() {
System.out.println("灯已打开");
}
}

View File

@ -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();
}
}

View File

@ -0,0 +1,8 @@
package com.greenorange.promotion.designModel;
public class TV {
public void turnOn() {
System.out.println("电视已打开");
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -0,0 +1,6 @@
package com.greenorange.promotion.factory;
public interface Computer {
void turnOn();
}

View File

@ -0,0 +1,7 @@
package com.greenorange.promotion.factory;
public abstract class ComputerFactory {
public abstract Computer createComputer();
}

View File

@ -0,0 +1,9 @@
package com.greenorange.promotion.factory;
public class DellComputer implements Computer{
@Override
public void turnOn() {
System.out.println("戴尔电脑开机");
}
}

View File

@ -0,0 +1,9 @@
package com.greenorange.promotion.factory;
public class DellFactory extends ComputerFactory{
@Override
public Computer createComputer() {
return new DellComputer();
}
}

View File

@ -0,0 +1,9 @@
package com.greenorange.promotion.factory;
public class LenovoComputer implements Computer{
@Override
public void turnOn() {
System.out.println("联想电脑开机");
}
}

View File

@ -0,0 +1,10 @@
package com.greenorange.promotion.factory;
public class LenovoFactory extends ComputerFactory {
@Override
public Computer createComputer() {
return new LenovoComputer();
}
}

View File

@ -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();
}
}