private static Bowl RollThirdBowl(Bowl bowl1) { short inputValue = 0; bool isInValidInput = true; while (isInValidInput) { Console.Write(" Extra Bowl "); string pinHit = Console.ReadLine(); isInValidInput = !(ValidateInputOtherBowl(pinHit, bowl1, out inputValue)); } return(new Bowl(inputValue)); }
private static Bowl RollSecondBowl(Bowl bowl1, short frameIndex) { short inputValue = 0; bool isInValidInput = true; if (bowl1.PinsDrop < 10 || frameIndex == 10) { while (isInValidInput) { Console.Write(" Bowl 2 "); string pinHit = Console.ReadLine(); isInValidInput = !(ValidateInputOtherBowl(pinHit, bowl1, out inputValue)); } } return(new Bowl(inputValue)); }
private static AbstractFrame GetInput(short frameIndex) { AbstractFrame frame = null; Console.WriteLine("Input for Frame-{0} ", frameIndex); Bowl bowl1 = RollFirstBowl(); Bowl bowl2 = RollSecondBowl(bowl1, frameIndex); frame = new Frame(bowl1, bowl2, frameIndex); if (frameIndex == 10 && (frame.IsStrike || frame.IsSpare)) { Bowl bowl3 = RollThirdBowl(bowl2); frame = new LastFrame(bowl1, bowl2, bowl3, frameIndex); } return(frame); }
private static bool ValidateInputOtherBowl(string input, Bowl first, out short value) { if (input.Length == 1 && input.ToLower().Contains('/')) { value = Convert.ToInt16(10 - first.PinsDrop); return(true); } if (input.Length == 1 && input.ToLower().Contains('x')) { value = 10; return(true); } if (input.Length == 1 && input.ToLower().Contains('-')) { value = 0; return(true); } return(Int16.TryParse(input, out value)); }
public Frame(Bowl bowl1, Bowl bowl2, short frameIndex) : base(bowl1, bowl2, frameIndex) { }
protected AbstractFrame(Bowl bowl1, Bowl bowl2, short frameIndex) : this(frameIndex) { FirstBowl = bowl1; SecondBowl = bowl2; }
private void GetPrintStatus(Bowl myBowl) { console.WriteLine(myBowl.ToString()); // More line of coding }
private static bool ValidateInputOtherBowl(string input, Bowl first, out short value) { if (input.Length == 1 && input.ToLower().Contains('/')) { value = Convert.ToInt16(10 - first.PinsDrop); return true; } if (input.Length == 1 && input.ToLower().Contains('x')) { value = 10; return true; } if (input.Length == 1 && input.ToLower().Contains('-')) { value = 0; return true; } return Int16.TryParse(input, out value); }
private static Bowl RollThirdBowl(Bowl bowl1) { short inputValue = 0; bool isInValidInput = true; while (isInValidInput) { Console.Write(" Extra Bowl "); string pinHit = Console.ReadLine(); isInValidInput = !(ValidateInputOtherBowl(pinHit, bowl1, out inputValue)); } return new Bowl(inputValue); }
private static Bowl RollSecondBowl(Bowl bowl1, short frameIndex) { short inputValue = 0; bool isInValidInput = true; if (bowl1.PinsDrop < 10 || frameIndex == 10) { while (isInValidInput) { Console.Write(" Bowl 2 "); string pinHit = Console.ReadLine(); isInValidInput = !(ValidateInputOtherBowl(pinHit, bowl1, out inputValue)); } } return new Bowl(inputValue); }
public void create_strike_bowl() { Bowl bowl = new Bowl(10); Assert.AreEqual(bowl.PinsDrop,10); }
public LastFrame(Bowl bowl1, Bowl bowl2, Bowl bowl3, short frameIndex) : base(bowl1, bowl2, frameIndex) { ExtraBowl = bowl3; }
public void should_exception_when_create_with_more_than_10_point() { Bowl bowl = new Bowl(11); Assert.Fail("Excepiton not thrown"); }
public void should_exception_when_create_with_less_then_zero_point() { Bowl bowl = new Bowl(-1); Assert.Fail("Excepiton not thrown"); }
public LastFrame(Bowl bowl1, Bowl bowl2,Bowl bowl3,short frameIndex) : base(bowl1,bowl2,frameIndex) { ExtraBowl = bowl3; }