//Button responses private void BtnFill_Click(object sender, RoutedEventArgs e) { StringBuilder BuildString = new StringBuilder(); IngredientNames Ingredient = CheckIngredent(); if (RadKettle.IsChecked == true) { BuildString.Append(VarKettle.Fill(Ingredient)); CheckContainerContents(Kettle); } if (RadBottle.IsChecked == true) { BuildString.Append(VarBottle.Fill(Ingredient)); CheckContainerContents(Bottle); } if (RadSpoon.IsChecked == true) { BuildString.Append(VarSpoon.Fill(Ingredient)); CheckContainerContents(Spoon); } if (RadCup.IsChecked == true) { BuildString.Append(VarCup.Fill(Ingredient)); CheckContainerContents(Cup); } VarStory.AddIngredient = BuildString.ToString(); VarStory.AddAddIngredientMessage = true; TxtOutput.Text = VarStory.UpdateStory(); BuildString.Clear(); }
public string Fill(IngredientNames ingredient, Containers From) { string OutputVar; StringBuilder BuildString = new StringBuilder(); IngredientNames Nothing = IngredientNames.Nothing; BuildString.Append(ingredient.ToString() + " has been added to " + this.Name.ToString() + " from " + From.ToString()); if (this.Contains1 == Nothing) { this.Contains1 = ingredient; if (this.Contains2 == null) { this.IsFull = true; } } else if (this.Contains2 == Nothing && this.Contains2 != null) { this.Contains2 = ingredient; if (this.Contains3 != Nothing) { this.IsFull = true; } } else if (this.Contains3 == Nothing && this.Contains3 != null) { Contains3 = ingredient; this.IsFull = true; } OutputVar = BuildString.ToString(); BuildString.Clear(); return(OutputVar); }
public string Fill(IngredientNames ingredient) { StringBuilder BuildString = new StringBuilder(); IngredientNames Nothing = IngredientNames.Nothing; string Value, OutputVar; Value = CheckName(); if (this.InHand == true) { if (ingredient != IngredientNames.Nothing) { if (this.IsFull == false) { BuildString.Append(Value + " has been filled with " + ingredient.ToString() + "\n"); if (Contains1 == Nothing) { Contains1 = ingredient; if (Contains2 == null) { this.IsFull = true; } } else if (Contains2 == Nothing && Contains2 != null) { Contains2 = ingredient; if (Contains3 != Nothing) { this.IsFull = true; } } else if (Contains3 == Nothing && Contains3 != null) { Contains3 = ingredient; this.IsFull = true; } } else { BuildString.Append(Value + " is already full, empty first!" + "\n"); } } else { BuildString.Append("You tried to fill the " + Value + " with fresh air alongside it's current contents. \n"); BuildString.Append("You gave up after a while..."); } } else { BuildString.Append("Might want to pick up this item before you try fill this item."); } OutputVar = BuildString.ToString(); BuildString.Clear(); return(OutputVar); }
/// <summary> /// Attempt to take out of the container using Spoon. Note: secondary use of "remove" function required /// </summary> /// <param name="Container">The Container to take out</param> /// <param name="Ingredient">The ingredient to take out</param> /// <returns>String value of the resulting story</returns> public string TakeOut(Containers Container, IngredientNames Ingredient) { StringBuilder BuildString = new StringBuilder(); if (Container == Containers.Cup) { if (Ingredient == IngredientNames.Teabag) { BuildString.Append("You take out the Teabag"); this.Contains1 = Ingredient; } else if (Ingredient != IngredientNames.Nothing) { BuildString.Append("You take out enough to fill the teaspoon - this of course does not affect the contents of the cup"); this.Contains1 = Ingredient; } else { BuildString.Append("Nothing was taken out"); } } else { if (Ingredient == IngredientNames.Teabag) { BuildString.Append("You take out the Teabags one by one - this takes some time"); this.Contains1 = Ingredient; } else if (Ingredient != IngredientNames.Nothing) { BuildString.Append("You take out enough to fill the teaspoon - this of course does not affect the contents of the " + Container); this.Contains1 = Ingredient; } else { BuildString.Append("Nothing was taken out"); } } return(BuildString.ToString()); }
/// <summary> /// Removes the identified ingredient - only works on teabags /// </summary> /// <param name="ingredient">Ingredient to be removed</param> /// <returns>Returns the amount of items that was removed</returns> public string RemoveItem(IngredientNames ingredient) { StringBuilder BuildString = new StringBuilder(); int count = 0; string OutputVar; if (ingredient == IngredientNames.Teabag) { if (this.Name != Containers.Kettle) { if (this.Contains1 == IngredientNames.Teabag) { this.Contains1 = IngredientNames.Nothing; count++; } if (this.Contains2 == IngredientNames.Teabag) { this.Contains2 = IngredientNames.Nothing; count++; } if (this.Contains3 == IngredientNames.Teabag) { this.Contains3 = IngredientNames.Nothing; count++; } BuildString.Append(count.ToString() + " teabags have been removed"); } else { BuildString.Append("A lot of teabags have been removed"); } } OutputVar = BuildString.ToString(); BuildString.Clear(); return(OutputVar); }
public string Empty() { StringBuilder BuildString = new StringBuilder(); IngredientNames Nothing = IngredientNames.Nothing; string Value, OutputVar; Value = CheckName(); if (this.IsFull == true | ( //Fix for cup not emptying right this.Name == Containers.Cup && (this.Contains1 != IngredientNames.Nothing | this.Contains2 != IngredientNames.Nothing | this.Contains3 != IngredientNames.Nothing) ) ) { BuildString.Append(Value + " has been emptied!" + "\n"); this.Contains1 = Nothing; if (this.Contains2 != null) { this.Contains2 = Nothing; } if (this.Contains3 != null) { this.Contains3 = Nothing; } this.IsFull = false; } else { BuildString.Append(Value + " is already empty!" + "\n"); } OutputVar = BuildString.ToString(); BuildString.Clear(); return(OutputVar); }
private void BtnPourIn_Click(object sender, RoutedEventArgs e) { StringBuilder BuildString = new StringBuilder(); Containers FromValue = CheckToContainer(); Containers ToValue = CheckContainerNames(); IngredientNames IngredientValue = IngredientNames.Nothing; bool?IsInHandFrom = false, IsInHandTo = false; //Checks the status of the content of the original //Also checks if the object is in hand currently switch (FromValue) { case Containers.Kettle: IngredientValue = VarKettle.Contains1; IsInHandFrom = VarKettle.InHand; break; case Containers.MilkBottle: IngredientValue = VarBottle.Contains1; IsInHandFrom = VarBottle.InHand; break; case Containers.Spoon: IngredientValue = VarSpoon.Contains1; IsInHandFrom = VarSpoon.InHand; break; case Containers.Cup: break; default: BuildString.Append("Nothing selected to pour from!"); break; } //Checks wether or not the object pouring to is in hand switch (ToValue) { case Containers.Kettle: IsInHandTo = VarKettle.InHand; break; case Containers.Cup: IsInHandTo = VarKettle.InHand; break; case Containers.MilkBottle: IsInHandTo = VarBottle.InHand; break; case Containers.Spoon: IsInHandTo = VarSpoon.InHand; break; default: BuildString.Append("Nothing selected to pour into!"); break; } if (IsInHandFrom == true && IsInHandTo == true) { if (IngredientValue != Nothing) { if (FromValue == ToValue) { BuildString.Append("...How do you propose to do that?"); } else { switch (ToValue) { case Containers.Kettle: if (FromValue != ToValue) { BuildString.Append(VarKettle.Fill(IngredientValue, FromValue) + "\n"); } break; case Containers.MilkBottle: if (FromValue != ToValue) { BuildString.Append(VarBottle.Fill(IngredientValue, FromValue) + "\n"); } break; case Containers.Spoon: if (FromValue != ToValue) { BuildString.Append(VarSpoon.Fill(IngredientValue, FromValue) + "\n"); } break; case Containers.Cup: if (FromValue != ToValue) { //BuildString.Append(VarCup.Fill(IngredientValue, FromValue)); } break; case Containers.None: break; } switch (FromValue) { case Containers.Kettle: BuildString.Append(VarKettle.Empty() + "\n"); break; case Containers.MilkBottle: BuildString.Append(VarBottle.Empty() + "\n"); break; case Containers.Spoon: BuildString.Append(VarBottle.Empty() + "\n"); break; case Containers.Cup: break; case Containers.None: break; } } } else { BuildString.Append("The original container does not have any ingredients in it!"); } } else { BuildString.Append("One or more containers is not in hand - check that you have both containers in hand!"); } VarStory.AddIngredient = BuildString.ToString(); VarStory.AddAddIngredientMessage = true; TxtOutput.Text = VarStory.UpdateStory(); CheckContainerContents(ToValue); BuildString.Clear(); }
public string TakeOut(IngredientNames ingredient) { StringBuilder BuildString = new StringBuilder(); string OutPutVar; if (!(ingredient == IngredientNames.Teabag && ingredient == IngredientNames.Nothing)) { BuildString.Append("Either through sheer grim determination or sheer boredom you manage to empty the " + this.Name.ToString() + "."); if (this.Name == Containers.Cup) { if (ingredient == IngredientNames.Milk) { BuildString.Append("Also you take out the Water..."); if (this.Contains1 == IngredientNames.Water) { Contains1 = IngredientNames.Nothing; } if (this.Contains2 == IngredientNames.Water) { Contains2 = IngredientNames.Nothing; } if (this.Contains3 == IngredientNames.Water) { Contains3 = IngredientNames.Nothing; } } else if (ingredient == IngredientNames.Water) { BuildString.Append("Also you take out the Milk..."); if (this.Contains1 == IngredientNames.Milk) { Contains1 = IngredientNames.Nothing; } if (this.Contains2 == IngredientNames.Milk) { Contains2 = IngredientNames.Nothing; } if (this.Contains3 == IngredientNames.Milk) { Contains3 = IngredientNames.Nothing; } } } BuildString.Append("Congratulations!"); if (this.Contains1 == ingredient) { Contains1 = IngredientNames.Nothing; } if (this.Contains2 == ingredient) { Contains2 = IngredientNames.Nothing; } if (this.Contains3 == ingredient) { Contains3 = IngredientNames.Nothing; } } else { BuildString.Append("Still trying to spoon out fresh air?"); } OutPutVar = BuildString.ToString(); BuildString.Clear(); return(OutPutVar); }