本文整理汇总了C#中Vegetable类的典型用法代码示例。如果您正苦于以下问题:C# Vegetable类的具体用法?C# Vegetable怎么用?C# Vegetable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vegetable类属于命名空间,在下文中一共展示了Vegetable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var produce = new List<object>();
var f1 = new Fruit("Apple",8.5,3);
// f1.Name = "Apple";
// f1.Weight = 4.6;
// f1.Quantity = 3;
produce.Add(f1);
var f2 = new Vegetable();
f2.Name = "Bananna";
f2.Weight = 4.9;
f2.Quantity = 7;
produce.Add(f2);
produce.Add(new Vegetable());
((Vegetable)produce[2]).Name = "Carrot";
((Vegetable)produce[2]).Weight = 9.6;
((Vegetable)produce[2]).Quantity = 14;
Console.WriteLine("There are "+produce.Count+" items");
foreach (var item in produce)
{
Console.WriteLine(item);
}
}
示例2: Add
/// <summary>
/// Puts the vegetable in the <see cref="Kitchen.Utensil"/>.
/// </summary>
/// <param name="vegetable">The vegetable.</param>
/// <returns>The result of the action.</returns>
public string Add(Vegetable vegetable)
{
return string.Format(
"Put the {0} in the {1}.\r\n" +
"(\"Double, double toil and trouble;\r\nFire burn, and cauldron bubble.\")",
vegetable,
this);
}
示例3: Cut
private void Cut(Vegetable vegetable)
{
if (vegetable == null)
{
throw new ArgumentNullException("Vegetable cannot be null");
}
vegetable.IsCut = true;
}
示例4: Add
public void Add(Vegetable vegetable)
{
if (vegetable.IsPeeled && vegetable.IsCut)
{
this.Content.Add(vegetable);
}
else
{
throw new ArgumentException("The vegetable shoud be peeled and cut.");
}
}
示例5: Cook
public void Cook(Vegetable vegetable)
{
vegetable = this.GetVegetable();
this.Peel(vegetable);
this.Cut(vegetable);
Bowl bowl = this.GetBowl();
bowl.BowlList.Add(vegetable);
}
示例6: Cook
// Methods
public void Cook(Vegetable item)
{
this.Peel(item);
this.Cut(item);
// Creating bowl
Bowl bowl = this.GetBowl();
// Adding the peeled and cut vegies
// to the bowl
bowl.AddVegetables(item);
}
示例7: AddVegetable
public void AddVegetable(Vegetable veg,Vector2 vegPosition)
{
if (vegPosition.x < 0 || vegPosition.x > 2 || vegPosition.y < 0 || vegPosition.y > 2) {
Debug.LogError ("<color=green>WRONG VEGETABLE POSITION</color>");
return;
}
else {
VegetableBoard[(int)vegPosition.x,(int)vegPosition.y] = (Vegetable)Instantiate(veg);
VegetableBoard[(int)vegPosition.x,(int)vegPosition.y].transform.SetParent(this.gameObject.transform);
VegetableBoard[(int)vegPosition.x,(int)vegPosition.y].transform.localPosition = new Vector3(vegPosition.x * 3, 0, vegPosition.y * 3);
}
}
示例8: Cook
public void Cook(Vegetable vegetable)
{
Potato potato = new Potato();
potato.Peel();
potato.Cut();
Carrot carrot = new Carrot();
carrot.Peel();
carrot.Cut();
Bowl bowl = new Bowl();
bowl.Add(potato);
bowl.Add(carrot);
}
示例9: Cook
public void Cook(Vegetable vegetable)
{
Potato potato = this.GetPotato();
Carrot carrot = this.GetCarrot();
this.Peel(potato);
this.Peel(carrot);
this.Cut(potato);
this.Cut(carrot);
Bowl bowl = this.GetBowl();
bowl.Add(carrot);
bowl.Add(potato);
}
示例10: Cut
private void Cut(Vegetable potato)
{
// ...
}
示例11: Peel
private void Peel(Vegetable vegetable)
{
// TODO: Implement this method
throw new NotImplementedException();
}
示例12: Add
internal void Add(Vegetable carrot)
{
throw new NotImplementedException();
}
示例13: Peel
private void Peel(Vegetable vegetable)
{
// some vegetable peeling logic
vegetable.IsPeeled = true;
}
示例14: Cut
private void Cut(Vegetable vegetable)
{
// some vegetable cutting logic
vegetable.IsCut = true;
}
示例15: Cut
public void Cut(Vegetable potato)
{
//...
}