/// <summary> /// generates questions at start of the game from files /// </summary> /// <param name="T"></param> public void InitializePlay(TaskContent T) { Console.WriteLine("Ok! Lets start the game!\n"); var rand = new Random(); this.AddContent(rand.Next(1, 10), 10, T.FirstSection, @"QA1.txt"); this.AddContent(rand.Next(1, 10), 100, T.SecondSection, @"QA2.txt"); this.AddContent(rand.Next(1, 10), 1000, T.ThirdSection, @"QA3.txt"); }
public int PlayThirdSect(TaskContent T, int prize) { int endprize = prize; Console.WriteLine("We start the last block of questions. Your current pize is " + prize); for (int i = 0; i < T.ThirdSection.Capacity; i++) { if (T.AskQuestion(3, i)) { prize += T.ThirdSection[i].Price; Console.WriteLine("You won " + prize); } else { return(endprize); } } return(prize); }
public void Run() { var currentTasks = new TaskContent(); int tempPrize = 0, Prize = 0; int Answer; this.InitializePlay(currentTasks); Console.Clear(); Prize = this.PlayFirstSect(currentTasks, tempPrize); if (Prize > tempPrize) { Console.Clear(); tempPrize = Prize; Prize = this.PlaySecondSect(currentTasks, tempPrize); if (Prize > tempPrize) { Console.Clear(); tempPrize = Prize; Prize = this.PlayThirdSect(currentTasks, tempPrize); if (Prize > tempPrize) { Console.WriteLine("Congratulation! You succesfully answer all questions! You won " + Prize); } else { Console.WriteLine("Sorry, your answer was wrong! Your total prize is " + Prize); } } else { Console.WriteLine("Sorry, your answer was wrong! Your total prize is " + Prize); } } else { Console.WriteLine("Sorry, your answer was wrong! Your total prize is " + Prize); } Console.ReadKey(); }