Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Tournament
- {
- public static void Simulation()
- {
- string path = @"..\\TournamentSimulation\Tournament.txt";
- if (!File.Exists(path))
- {
- //Create a file to write to
- using (StreamWriter sw = File.CreateText(path))
- {
- }
- }
- Console.WriteLine("What is the name of the tournament?");
- string TournamentName = Console.ReadLine();
- Console.WriteLine("When does the tournament start? (mm-dd-yyyy)");
- DateTime TournamentStart = Convert.ToDateTime(Console.ReadLine());
- Console.WriteLine("When does the tournament end? (mm-dd-yyyy)");
- DateTime TournamentEnd = Convert.ToDateTime(Console.ReadLine());
- Console.WriteLine("How many players are in the tournament? " +
- "Please choose 8, 16, 32 or 64");
- int TournamentPlayers = Convert.ToInt32(Console.ReadLine());
- if (TournamentPlayers == 8 || TournamentPlayers == 16 || TournamentPlayers == 32
- || TournamentPlayers == 64)
- {
- Console.WriteLine("There are {0} players in the tournament and {1} referees"
- , TournamentPlayers, TournamentPlayers / 2);
- using (StreamWriter sw = File.AppendText(path))
- {
- sw.WriteLine("Tournament name: " + TournamentName);
- sw.WriteLine("Tournament start date: " + TournamentStart);
- sw.WriteLine("Tournament end date: " + TournamentEnd);
- sw.WriteLine("There are {0} players in the tournament called {1}."
- , TournamentPlayers, TournamentName);
- sw.WriteLine("There are {0} matches in the first round."
- , TournamentPlayers / 2);
- sw.WriteLine("There are {0} matches in the second round, " +
- "between {1} winners from round 1.", TournamentPlayers / 4, TournamentPlayers / 2);
- if (TournamentPlayers == 8)
- {
- sw.WriteLine("There is {0} match in the third round (the final), " +
- "between {1} winners from round 2.", TournamentPlayers / 8, TournamentPlayers / 4);
- }
- else if (TournamentPlayers == 16)
- {
- sw.WriteLine("There are {0} matches in the third round, " +
- "between {1} winners from round 2.", TournamentPlayers / 8, TournamentPlayers / 4);
- sw.WriteLine("There is {0} match in the fourth round (the final), " +
- "between {1} winners from round 2.", TournamentPlayers / 16, TournamentPlayers / 8);
- }
- else if (TournamentPlayers == 32)
- {
- sw.WriteLine("There are {0} matches in the third round, " +
- "between {1} winners from round 2.", TournamentPlayers / 8, TournamentPlayers / 4);
- sw.WriteLine("There are {0} matches in the fourth round, " +
- "between {1} winners from round 2.", TournamentPlayers / 16, TournamentPlayers / 8);
- sw.WriteLine("There is {0} match in the fifth round (the final), " +
- "between {1} winners from round 2.", TournamentPlayers / 32, TournamentPlayers / 16);
- }
- else if (TournamentPlayers == 64)
- {
- sw.WriteLine("There are {0} matches in the third round, " +
- "between {1} winners from round 2.", TournamentPlayers / 8, TournamentPlayers / 4);
- sw.WriteLine("There are {0} matches in the fourth round, " +
- "between {1} winners from round 2.", TournamentPlayers / 16, TournamentPlayers / 8);
- sw.WriteLine("There are {0} matches in the fifth round, " +
- "between {1} winners from round 2.", TournamentPlayers / 32, TournamentPlayers / 16);
- sw.WriteLine("There is {0} match in the sixth round (the final), " +
- "between {1} winners from round 2.", TournamentPlayers / 64, TournamentPlayers / 32);
- }
- sw.WriteLine(" ");
- }
- }
- else
- {
- Console.WriteLine("You have to choose 8, 16, 32 or 64 players");
- }
- using (StreamReader sr = File.OpenText(path))
- {
- string s = "";
- while ((s = sr.ReadLine()) != null)
- {
- Console.WriteLine(s);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement