示例#1
0
        public Fruit CreateFruit(FruitTypes type, Position position)
        {
            switch (type)
            {
            case FruitTypes.Apple:
                _fruitBuilder = new AppleBuilder(position);
                break;

            case FruitTypes.Cherry:
                _fruitBuilder = new CherryBuilder(position);
                break;

            case FruitTypes.Grapes:
                _fruitBuilder = new GrapesBuilder(position);
                break;

            case FruitTypes.Lemon:
                _fruitBuilder = new LemonBuilder(position);
                break;

            case FruitTypes.Orange:
                _fruitBuilder = new OrangeBuilder(position);
                break;

            case FruitTypes.Strawberry:
                _fruitBuilder = new StrawberryBuilder(position);
                break;

            default:
                throw new ArgumentException($"Not supported fruit type {type}");
            }

            return(_fruitBuilder.Instance);
        }
示例#2
0
 public Fruit(string title,
     string manufacterer,
     string countryOfManufacturer,
     IMeasuredValue weight,
     IMeasuredValue price,
     IMeasuredValue sugarValue,
     FruitTypes type)
     : base(title, manufacterer, countryOfManufacturer, weight, price)
 {
     _SugarValue = sugarValue;
     _Type = type;
 }
示例#3
0
        public IFruit GetFruit(FruitTypes fruitType)
        {
            switch (fruitType)
            {
            case FruitTypes.small:
                return(new SmallFruit());

            case FruitTypes.medium:
                return(new MediumFruit());

            default:
                return(new BigFruit());
            }
        }