Beispiel #1
0
        // this method is our factory method for now, if it gets more responsibilities, this
        // logic can move to a separate factory class
        public Tablet BuyTablet(bool withCellular, bool isGray)
        {
            var tablet = new Tablet(); // base version

            if (withCellular)
            {
                tablet = new CellularChipTabletDecorator(tablet);
            }
            if (isGray)
            {
                tablet = new SpaceGrayTabletDecorator(tablet);
            }
            else
            {
                tablet = new SilverTabletDecorator(tablet);
            }
            return(tablet);
        }
Beispiel #2
0
 public SpaceGrayTabletDecorator(Tablet tablet)
 {
     _delegateField = tablet;
 }
Beispiel #3
0
 public SilverTabletDecorator(Tablet tablet)
 {
     _delegateField = tablet;
 }
Beispiel #4
0
 public CellularChipTabletDecorator(Tablet tablet)
 {
     _delegateField = tablet;
 }