原型模式(prototype)[2]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

            public Color(int red, int green, int blue){

                        this.red=red;

                        this.green=green;

                        this.blue=blue;

            }

            public ColorPrototype cloneMe() throws CloneNotSupportedException{

                        //浅拷贝

                        return (ColorPrototype)super.clone();

            }

            public void Display(){

                        System.out.println(“RGB values are :” + red +”,”+ green+”,”+blue);

            }

}

 

//prototype manager

import java.util.*;

 

public class ColorManager{

            Hashtable colors=new Hashtable();

 

            public ColorPrototype getColor(String name){

本文关键:原型模式(prototype)
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top