// 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); }
public SpaceGrayTabletDecorator(Tablet tablet) { _delegateField = tablet; }
public SilverTabletDecorator(Tablet tablet) { _delegateField = tablet; }
public CellularChipTabletDecorator(Tablet tablet) { _delegateField = tablet; }