コード例 #1
0
        // Simple Factory Method
        public static Laptop Get(LaptopTypeEnum type)
        {
            switch (type)
            {
            case LaptopTypeEnum.Dell:
                return(new Dell());

            case LaptopTypeEnum.Mac:
                return(new Mac());

            default:
                return(new Acer());
            }
        }
コード例 #2
0
        public static Laptop Get(LaptopTypeEnum type)
        {
            switch (type)
            {
            case LaptopTypeEnum.Dell:
                return(new Dell());

            case LaptopTypeEnum.Asus:
                return(new Asus());

            case LaptopTypeEnum.Lenovo:
                return(new Lenovo());

            case LaptopTypeEnum.Acer:
            default:
                return(new Acer());
            }
        }
コード例 #3
0
 public Laptop(string name, LaptopTypeEnum laptopType) : base(name)
 {
     LaptopType         = laptopType;
     computerDefinition = new ForMacOs();
 }