工厂模式
来源:互联网 发布:淘宝假单号哪里买 编辑:程序博客网 时间:2024/05/18 18:55
// 工厂模式 public static <T extends Computer> T getComputer(Class <T> clz) { Computer computer = null; try { computer = (Computer) Class.forName(clz.getName()).newInstance(); } catch (Exception e) { e.printStackTrace(); } return (T) computer; }
Computer
public class Computer { private String cpu; // cpu private String graphicsCard; // 显卡 private String motherBoard; // 主板 private String memory; // 内存 private String hardDsik; // 硬盘 private String display; // 显示器 public String getCpu() { return cpu; } public void setCpu(String cpu) { this.cpu = cpu; } public String getGraphicsCard() { return graphicsCard; } public void setGraphicsCard(String graphicsCard) { this.graphicsCard = graphicsCard; } public String getMotherBoard() { return motherBoard; } public void setMotherBoard(String motherBoard) { this.motherBoard = motherBoard; } public String getMemory() { return memory; } public void setMemory(String memory) { this.memory = memory; } public String getHardDsik() { return hardDsik; } public void setHardDsik(String hardDsik) { this.hardDsik = hardDsik; } public String getDisplay() { return display; } public void setDisplay(String display) { this.display = display; }}
ComputerA
public class ComputerA extends Computer{}
0 0
- 工厂模式 -- 工厂方法
- 工厂模式 -- 抽象工厂
- 工厂模式-简单工厂
- 工厂模式-工厂方法
- 工厂模式:静态工厂
- 工厂模式-简单工厂
- 工厂模式-抽象工厂
- 工厂模式-工厂方法
- 工厂 > 工厂方法模式
- 工厂模式-静态工厂
- 工厂模式-抽象工厂
- 工厂模式
- 工厂模式
- 工厂模式
- 工厂模式
- 工厂模式
- 工厂模式
- 工厂模式
- TextView相关
- 为什么要用实现接口的类实例化接口呢
- 接口和自定义观察者模式
- spring bom 解决spring依赖多版本问题
- IOS中 UIFont 字体大全
- 工厂模式
- VMware Ubuntu虚拟机linux内核版本从2.6.22升级到3.6.0-rc7
- android之官方下拉刷新组件SwipeRefreshLayout
- Java随记
- CodeForces 373C Counting Kangaroos is Fun(袋鼠藏口袋,二分)
- 【数组7】把数组排成最小的数
- 努力就可以上清华北大吗?(转载)
- 在自己的VS10里添加了.h文件后,如何包含这个头文件的路径的方法
- Cow Bowling 数字三角形 初步动态规划