static void Main() { string playagain = ""; Lottery lotozabava = new Lottery(); while (playagain != "no") { Console.WriteLine("Hi. This is a lottery."); LotteryTicket lotterydeal = new LotteryTicket(); Startgame: Console.WriteLine($"\nYou are required to enter {lotozabava.ticketsize} numbers in a range from {lotozabava.minrange} to {lotozabava.maxrange}."); Console.WriteLine($"The system will than generate it's own {lotozabava.ticketsize} numbers and match them with yours. Let's see who wins :)"); Console.WriteLine("\nCAUTION: Please enter single number in a row. \n"); UserTicket happyticket = lotozabava.FillTicket(); lotozabava.LotteryResult(happyticket, lotterydeal); lotozabava.SaveLotteryDealHistory(happyticket, lotterydeal, lotozabava); ContinuePlaying: Console.WriteLine("\nDo you want to play again? Type 'yes' or 'no'. If you want to see play history, type 'h'"); playagain = Console.ReadLine(); switch (playagain) { case "yes": goto Startgame; case "no": continue; case "h": for (int i = 0; i < lotozabava.results.Count; i++) { Console.WriteLine(lotozabava.results[i]); } goto ContinuePlaying; default: goto ContinuePlaying; } } Console.WriteLine("\nThanks for playing! Bye!"); }
public void SaveLotteryDealHistory(UserTicket userticket, LotteryTicket lotteryticket, Lottery lottery) { string userhistory = string.Join(" ", userticket.tickets); string lotteryhistory = string.Join(" ", lotteryticket.tickets); string totalhistory = "Play History. User Ticket: " + userhistory + " Lottery Deal " + lotteryhistory + " Lottery won: " + lottery.lotteryresult; results.Add(totalhistory); }