Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 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));
 }
Esempio n. 5
0
 public Frame(Bowl bowl1, Bowl bowl2, short frameIndex)
     : base(bowl1, bowl2, frameIndex)
 {
 }
Esempio n. 6
0
 protected AbstractFrame(Bowl bowl1, Bowl bowl2, short frameIndex)
     : this(frameIndex)
 {
     FirstBowl = bowl1;
     SecondBowl = bowl2;
 }
Esempio n. 7
0
 private void GetPrintStatus(Bowl myBowl)
 {
     console.WriteLine(myBowl.ToString());
     // More line of coding
 }
Esempio n. 8
0
 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);
 }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
 }
Esempio n. 12
0
 private void GetPrintStatus(Bowl myBowl)
 {
     console.WriteLine(myBowl.ToString());
     // More line of coding
 }
Esempio n. 13
0
 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");
 }
Esempio n. 16
0
 protected AbstractFrame(Bowl bowl1, Bowl bowl2, short frameIndex)
     : this(frameIndex)
 {
     FirstBowl  = bowl1;
     SecondBowl = bowl2;
 }
Esempio n. 17
0
 public LastFrame(Bowl bowl1, Bowl bowl2,Bowl bowl3,short frameIndex)
     : base(bowl1,bowl2,frameIndex)
 {
     ExtraBowl = bowl3;
 }
Esempio n. 18
0
 public Frame(Bowl bowl1, Bowl bowl2, short frameIndex) : base(bowl1, bowl2, frameIndex)
 {
 }