当前位置:网站首页>Factorymethod factory method
Factorymethod factory method
2022-06-25 22:04:00 【Daily enlightenment】
Convenient product dimension extension .
(1)CarFactory
public class CarFactory {
public Moveable create() {
System.out.println("a car created!");
return new Car();
}
}
(2)BroomFactory
public class BroomFactory {
public Moveable create() {
System.out.println("a Broom created!");
return new Broom();
}
}(3)Moveable
public interface Moveable {
void go();
}
(4)Car
public class Car implements Moveable {
@Override
public void go() {
System.out.println("Car go ....");
}
}(5)Broom
public class Broom implements Moveable{
@Override
public void go() {
System.out.println("broom flying .....");
}
}(6)Main
public class Main {
public static void main(String[] args) {
//Moveable m = new CarFactory().create();
//m.go();
Moveable m = new BroomFactory().create();
m.go();
}
}边栏推荐
- Simple record of fire & spell effects
- leetcode: 49. Grouping of alphabetic words
- Some websites used by Beijing University of technology when graduating
- HNU计网实验:实验五 网络层与链路层协议分析(PacketTracer)
- 【Proteus仿真】Arduino UNO花样流水灯
- Preliminary solution of i/o in socket programming
- JS limit mouse movement range
- HNU计网实验:实验四 应用层和传输层协议分析(PacketTracer)
- Zhiyun health is about to go public: long-term losses, meinian health Yu Rong has withdrawn, and it is difficult to be optimistic about the future
- Will neuvector be the next popular cloud native security artifact?
猜你喜欢

HNU network counting experiment: experiment I application protocol and packet analysis experiment (using Wireshark)

js禁用浏览器 pdf 打印、下载功能(pdf.js 禁用打印下载、功能)

Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing Bing

PHP Chinese word segmentation API, Harbin Institute of technology ltpcloud, naturallanguageprocessing, free, best practices!

Type conversion basis

“No bean named ‘UserController‘ available“

Illustration de l'exécution du cadre de pile
Oracle case: does index range scan really not read multiple blocks?
What is the difficulty of the form tool that costs billions of dollars? Exclusive interview with si no

Canoe learning notes (1)
随机推荐
Research on depth image compression in YUV420 color space
No nonsense, code practice will help you master strong caching and negotiation caching!
什么是代码基线?
[WPF] XAML code skills that can be directly used for converting CAD engineering drawings to WPF
Did you really learn the right game modeling with 3DMAX?
Simple record of fire & spell effects
idea怎么把自己的项目打包成jar包
熊市指南|一些本质的教训与具体的生存法则
Pat 1073 scientific notation (20 points) (18 points not finished)
js禁用浏览器 pdf 打印、下载功能(pdf.js 禁用打印下载、功能)
Simulate ATM system (account opening, login, account query, withdrawal, deposit, transfer, password modification, account cancellation)
【Proteus仿真】Arduino UNO+按键控制2位数码管倒计时
Php7.4 arm environment compilation and installation error invalid 'ASM': invalid operate prefix '%c'
leetcode: 49. Grouping of alphabetic words
数学分析_笔记_第4章:连续函数类和其他函数类
Build the first website with idea
HNU network counting experiment: experiment I application protocol and packet analysis experiment (using Wireshark)
HLS. JS: past, present and future
MySQL Chapter 15 lock
Obsidian基础教程