public interface IClone { object Clone(); }
原型接口
using System; public class NiceGirl:IClone { private string _Name; private string _Tall; private string _SkinColor; private string _HairColor; private string _Weight; private string _Colthes; private string _Shoes; private string _Bag; public NiceGirl() { } private NiceGirl(NiceGirl nicegirl) { _Name = nicegirl.Name; _Tall = nicegirl.Tall; _SkinColor = nicegirl.SkinColor; _HairColor = nicegirl.HairColor; _Weight = nicegirl.Weight; _Colthes = nicegirl.Colthes; _Shoes = nicegirl.Shoes; _Bag = nicegirl.Bag; } public string Name { get { return _Name; } set { _Name = value; } } public string Tall { get { return _Tall; } set { _Tall = value; } } public string SkinColor { get { return _SkinColor; } set { _SkinColor = value; } } public string HairColor { get { return _HairColor; } set { _HairColor = value; } } public string Weight { get { return _Weight; } set { _Weight = value; } } public string Colthes { get { return _Colthes; } set { _Colthes = value; } } public string Shoes { get { return _Shoes; } set { _Shoes = value; } } public string Bag { get { return _Bag; } set { _Bag = value; } } public override string ToString() { string decorationList = string.Empty; decorationList += "Name:" + this.Name + "/n" + "Tall:" + this.Tall + "/n" + "SkinColor:" + this.SkinColor + "/n" + "HairColor:" + this.HairColor + "/n" + "Weight:" + this.Weight + "/n" + "Clothes:" + this.Colthes + "/n" + "Shoes:" + this.Shoes + "/n" + "Bag:" + this.Bag; return decorationList; } #region IClone 成员 public object Clone() { return new NiceGirl(this); } #endregion }
原型接口的实现者A
using System; using System.Collections.Generic; using System.Text; namespace PrototypePattern { class Program { static void Main(string[] args) { NiceGirl nicegirl = new NiceGirl(); nicegirl.Name = "露西"; nicegirl.Tall = "170CM"; nicegirl.Weight = "55KG"; nicegirl.SkinColor = "奶白色"; nicegirl.HairColor = "酒红色"; nicegirl.Shoes = "水晶色的低跟鞋"; nicegirl.Bag = "牛仔帆布袋"; Console.WriteLine("==========================One Girl====================================="); Console.WriteLine(nicegirl.ToString()); Console.WriteLine("==========================One Girl====================================="); NiceGirl nicegirl2 = nicegirl.Clone() as NiceGirl; Console.WriteLine("==========================Two Girl====================================="); Console.WriteLine(nicegirl2.ToString()); Console.WriteLine("==========================Two Girl====================================="); Console.ReadLine(); } } }
调用者
您还没有登录,请您登录后再发表评论
原型模式(Prototype Pattern)是用于创建重复的对象,同时又能保证性能。这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式。
6、原型模式(Prototype Pattern) 用意:通过拷贝创建一个新的对象
原型模式是一种创建型设计模式,它通过复制一个现有的对象来创建新的对象,而不是通过调用构造函数的方式。这种方式可以在运行时动态地创建和修改对象,而不需要知道具体的创建细节 。 原型模式的基本概念包括以下...
NULL 博文链接:https://jacky-dai.iteye.com/blog/2295379
.NET设计模式(6):原型模式(PrototypePattern)
适配器模式(Adapter Pattern) 提供者模式(Provider Pattern) 外观模式(Facade Pattern) 享元模式(Flyweight Pattern) 原型模式(Prototype Pattern) 责任链模式(Chain of Responsibility Pattern) 中介者模式...
用Java实现23种设计模式 1. 创建型模式 工厂模式(Factory Pattern) 抽象工厂模式(Abstract Factory Pattern) 单例模式(Singleton Pattern) 建造者模式(Builder Pattern) 原型模式(Prototype Pattern)...
原型模式(Prototype Pattern)是用于创建重复的对象,同时又能保证性能。这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式。 这种模式是实现了一个原型接口,该接口用于创建当前对象的克隆。当...
原型模式(Prototype Pattern) 单例模式(Singleton Pattern) 结构型模式用来处理类或者对象的组合,主要包含以下7种设计模式: 适配器模式(Adapter Pattern) 桥接模式(Bridge Pattern) 组合...
原型模式(Prototype Pattern) 2 结构型模式 这些设计模式关注类和对象的组合。继承的概念被用来组合接口和定义组合对象获得新功能的方式。 适配器模式(Adapter Pattern) 桥接模式(Bridge Pattern) 过滤器模式...
1. 设计模式 1.1 含义 1.2 作用 1.3 设计原则 1.4 分类 2. 简单工厂模式 (SimpleFactoryPattern) 3. 工厂方法模式 (Factory Method) 4. 单例模式 (Singleton) 5. 抽象工厂模式 (Abstract Factory) 6. ...
23种设计模式(Design Pattern)的C++实现范例,包括下面列出的各种模式,代码包含较详细注释。另外附上“设计模式迷你手册.chm” 供参考。 注:项目在 VS2008 下使用。 创建型: 抽象工厂模式(Abstract Factory) ...
36种最新设计模式整理 Design Pattern: Simple Factory 模式 Design Pattern: Abstract Factory 模式 Design Pattern: Builder 模式 Design Pattern: Factory Method 模式 Design Pattern: Prototype 模式 ...
原型模式(Prototype)结构型: 6. 适配器模式(Adapter Pattern) 7. 桥接模式(Bridge Pattern) 8. 装饰模式(Decorator Pattern) 9. 组合模式(Composite Pattern) 10. 外观模式(Facade Pattern) 11. 享元模式...
本文实例讲述了Python设计模式之原型模式。分享给大家供大家参考,具体如下: 原型模式(Prototype Pattern):用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象 一个原型模式的简单demo: #!/usr/bin/...
(100%) 设计模式面面观(5):抽象工厂模式(AbstractFactory)-创建型模式 (100%) 设计模式面面观(6):生成器模式(Builder)-创建型模式 (100%) 设计模式面面观(7):原型模式(Prototype)-...
3.4 Prototype(原型)—对象创建型 模式 87 3.5 Singleton(单件)—对象创建型 模式 84 3.6 创建型模式的讨论 89 第4章 结构型模式 91 4.1 Adapter(适配器)—类对象结构型 模式 92 4.2 Bridge(桥接)—对象结构...
相关推荐
原型模式(Prototype Pattern)是用于创建重复的对象,同时又能保证性能。这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式。
原型模式(Prototype Pattern)是用于创建重复的对象,同时又能保证性能。这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式。
6、原型模式(Prototype Pattern) 用意:通过拷贝创建一个新的对象
原型模式是一种创建型设计模式,它通过复制一个现有的对象来创建新的对象,而不是通过调用构造函数的方式。这种方式可以在运行时动态地创建和修改对象,而不需要知道具体的创建细节 。 原型模式的基本概念包括以下...
NULL 博文链接:https://jacky-dai.iteye.com/blog/2295379
.NET设计模式(6):原型模式(PrototypePattern)
适配器模式(Adapter Pattern) 提供者模式(Provider Pattern) 外观模式(Facade Pattern) 享元模式(Flyweight Pattern) 原型模式(Prototype Pattern) 责任链模式(Chain of Responsibility Pattern) 中介者模式...
用Java实现23种设计模式 1. 创建型模式 工厂模式(Factory Pattern) 抽象工厂模式(Abstract Factory Pattern) 单例模式(Singleton Pattern) 建造者模式(Builder Pattern) 原型模式(Prototype Pattern)...
原型模式(Prototype Pattern)是用于创建重复的对象,同时又能保证性能。这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式。 这种模式是实现了一个原型接口,该接口用于创建当前对象的克隆。当...
原型模式(Prototype Pattern) 单例模式(Singleton Pattern) 结构型模式用来处理类或者对象的组合,主要包含以下7种设计模式: 适配器模式(Adapter Pattern) 桥接模式(Bridge Pattern) 组合...
原型模式(Prototype Pattern) 2 结构型模式 这些设计模式关注类和对象的组合。继承的概念被用来组合接口和定义组合对象获得新功能的方式。 适配器模式(Adapter Pattern) 桥接模式(Bridge Pattern) 过滤器模式...
1. 设计模式 1.1 含义 1.2 作用 1.3 设计原则 1.4 分类 2. 简单工厂模式 (SimpleFactoryPattern) 3. 工厂方法模式 (Factory Method) 4. 单例模式 (Singleton) 5. 抽象工厂模式 (Abstract Factory) 6. ...
23种设计模式(Design Pattern)的C++实现范例,包括下面列出的各种模式,代码包含较详细注释。另外附上“设计模式迷你手册.chm” 供参考。 注:项目在 VS2008 下使用。 创建型: 抽象工厂模式(Abstract Factory) ...
36种最新设计模式整理 Design Pattern: Simple Factory 模式 Design Pattern: Abstract Factory 模式 Design Pattern: Builder 模式 Design Pattern: Factory Method 模式 Design Pattern: Prototype 模式 ...
原型模式(Prototype)结构型: 6. 适配器模式(Adapter Pattern) 7. 桥接模式(Bridge Pattern) 8. 装饰模式(Decorator Pattern) 9. 组合模式(Composite Pattern) 10. 外观模式(Facade Pattern) 11. 享元模式...
本文实例讲述了Python设计模式之原型模式。分享给大家供大家参考,具体如下: 原型模式(Prototype Pattern):用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象 一个原型模式的简单demo: #!/usr/bin/...
(100%) 设计模式面面观(5):抽象工厂模式(AbstractFactory)-创建型模式 (100%) 设计模式面面观(6):生成器模式(Builder)-创建型模式 (100%) 设计模式面面观(7):原型模式(Prototype)-...
3.4 Prototype(原型)—对象创建型 模式 87 3.5 Singleton(单件)—对象创建型 模式 84 3.6 创建型模式的讨论 89 第4章 结构型模式 91 4.1 Adapter(适配器)—类对象结构型 模式 92 4.2 Bridge(桥接)—对象结构...