原型模式 Prototype(创建型模式)
1.概述
所谓原型模式就是用原型实例指定创建对象的种类,并且通过复制这些原型创建新的对象。
2.例子
School类
1 public class School { 2 3 String schoolName ; 4 String adress ; 5 6 public School(String schoolName, String adress) { 7 super(); 8 this.schoolName = schoolName; 9 this.adress = adress; 10 } 11 12 public String getSchoolName() { 13 return schoolName; 14 } 15 16 public void setSchoolName(String schoolName) { 17 this.schoolName = schoolName; 18 } 19 20 public String getAdress() { 21 return adress; 22 } 23 24 public void setAdress(String adress) { 25 this.adress = adress; 26 } 27 28 public School() { 29 // TODO Auto-generated constructor stub 30 } 31 32 }