예제 #1
0
 public override bool Equals(object obj)
 {
     if ((obj == null) || !this.GetType().Equals(obj.GetType()))
     {
         return(false);
     }
     else
     {
         Chocolate bev = (Chocolate)obj;
         return(base.Name.Equals(bev.Name));
     }
 }
 private Beverage CreateBeverage(string bev)
 {
     if (bev.Equals(dr1))
     {
         Beverage freshCoffee = new Coffee();
         return(freshCoffee);
     }
     else if (bev.Equals(dr2))
     {
         Beverage blackTea = new BlackTea();
         return(blackTea);
     }
     else if (bev.Equals(dr3))
     {
         Beverage greenTea = new GreenTea();
         return(greenTea);
     }
     else if (bev.Equals(dr4))
     {
         Beverage latte = new Latte();
         return(latte);
     }
     else if (bev.Equals(dr5))
     {
         Beverage chocolate = new Chocolate();
         return(chocolate);
     }
     else if (bev.Equals(dr6))
     {
         Beverage mintTea = new MintTea();
         return(mintTea);
     }
     else
     {
         return(null);
     }
 }