Ejemplo n.º 1
0
 public Pizza(PizzaType pizzaType, string composition, double ingredientWeight)
 {
     this.pizzaType        = pizzaType;
     this.composition      = composition;
     this.ingredientWeight = ingredientWeight;
     builder = new StringBuilder();
     builder.Append(pizzaType.ToString()).Append(" ").Append(name).Append(" with ").
     Append(composition).Append(" ").Append(ingredientWeight).Append(" gr.");
 }
Ejemplo n.º 2
0
 private void btnAddToSale_Click(object sender, RoutedEventArgs e)
 {
     if (ValidateQuantity(selectedPizza) > 0)
     {
         lstSale.Items.Add(txtQuantity.Text + " " + selectedPizza.ToString() +
                           ":" + txtPrice.Text + " " + double.Parse(txtQuantity.Text) *
                           double.Parse(txtPrice.Text));
         Total         = Total + double.Parse(txtQuantity.Text) * double.Parse(txtPrice.Text);
         txtTotal.Text = Total.ToString();
     }
     else
     {
         MessageBox.Show("Cantitatea introdusa nu este disponibila in stoc!");
     }
 }
        public static Pizza PizzaFactory(PizzaType pizzaType)
        {
            switch (pizzaType)
            {
            case PizzaType.HamNushroom:
                return(new HamAndMushroomPizza());

            case PizzaType.Deluxe:
                return(new DeluxePizza());

            case PizzaType.Seafood:
                return(new SeafoodPizza());
            }

            throw new System.NotSupportedException("The pizza type " + pizzaType.ToString() + " is not recognized");
        }
        public static Pizza PizzaFactory(PizzaType pizzaType)   // Factory METHOD- creator
        {
            switch (pizzaType)
            {
            case PizzaType.HamMushroom:
                return(new HamAndMushroomPizza());

            case PizzaType.Deluxe:
                return(new DeluxePizza());

            case PizzaType.Hawaiian:
                return(new HawaiianPizza());

            default:
                break;
            }

            throw new System.NotSupportedException("The pizza type " + pizzaType.ToString() + " is not recognized.");
        }
Ejemplo n.º 5
0
    // PizzaFactory Method
    public static Pizza PizzaFactory(PizzaType pizzaType)
    {
        // Parameter로 PizzaType을 넣으면 Switch에 해당하는 Class객체가 Return된다.
        // * Pizza는 Based Class(기반 클래스)이고, return값은 Inheritance Class(파생 클래스)이다. *
        //
        switch (pizzaType)
        {
        case PizzaType.HamMushroom:
            return(new HamAndMushroomPizza());

        case PizzaType.Deluxe:
            return(new DeluxePizza());

        case PizzaType.Seafood:
            return(new SeafoodPizza());
        }

        throw new System.NotSupportedException("The pizza type " + pizzaType.ToString() + " is not recognized.");
    }