示例#1
0
        public string[] PlayChampionship(Championship teams)
        {
            //обнуление количества голов
            for (int i = 0; i < 6; i++)
            {
                teams.GetTeam(i).Goals     = 0;
                teams.GetTeam(i).TeamScore = 0;

                for (int j = 0; j < 11; j++)
                {
                    teams.GetTeam(i).GetFootballer(j).Goals = 0;
                }
            }

            string[] StoryOfMatches = new string[30];
            int      num            = 0;

            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    if (i != j)
                    {
                        StoryOfMatches[num] = PlayMatch(teams.GetTeam(i), teams.GetTeam(j));
                        num++;
                    }
                }
            }
            return(StoryOfMatches);
        }
示例#2
0
        public void PrintLeaderBoard(Championship championship)
        {
            Console.WriteLine("================ LEADERBOARD ================");
            Console.WriteLine(String.Format("|{0,10}|{1,5}|{2,5}|", "   Team   ", "Score", "Goals"));

            for (int i = 0; i < 6; i++)
            {
                Console.WriteLine(String.Format("|{0,10}|{1,5}|{2,5}|", championship.GetTeam(i).FootballTeamName, championship.GetTeam(i).TeamScore, championship.GetTeam(i).Goals));
            }
        }
示例#3
0
 public void PrintTeamsSquads(Championship teams)
 {
     for (int i = 0; i < 6; i++)
     {
         Console.WriteLine($"========{teams.GetTeam(i).FootballTeamName}========");
         for (int j = 0; j < 11; j++)
         {
             Console.WriteLine($"{j + 1}. " + teams.GetTeam(i).GetTeamPlayerName(j));
         }
         Console.WriteLine();
     }
 }
示例#4
0
 public void PrintTeamStats(Championship teams, string teamName)
 {
     for (int i = 0; i < 6; i++)
     {
         if (teams.GetTeam(i).FootballTeamName == teamName)
         {
             for (int j = 0; j < 11; j++)
             {
                 Console.WriteLine(String.Format("|{0,20}|{1,5}|", teams.GetTeam(i).GetTeamPlayerName(j), teams.GetTeam(i).GetFootballerGoals(j)));
             }
         }
     }
 }
示例#5
0
        static void Main(string[] args)
        {
            string[][] playerNames = new string[6][];

            for (int i = 0; i < 6; i++)
            {
                playerNames[i] = new string[11];
            }

            string[] teamNames = new string[6] {
                "Dynamo", "Shakhtar", "Zoria", "Dnipro", "Metalist", "Kolos"
            };

            string[] path = new string[6];

            for (int i = 0; i < 6; i++)
            {
                path[i]        = @"D:\Course Work 2021\Input\" + teamNames[i] + ".txt";
                playerNames[i] = FileInput(playerNames[i], path[i]);
            }

            /*1 - Dynamo
            * 2 - Shakhtar
            * 3 - Zoria
            * 4 - Dnipro
            * 5 - Metalist
            * 6 - Kolos*/

            //creating a list with all the teams in th championship and initialization of the first object FootballTeam
            List <FootballTeam> TeamsValue = new List <FootballTeam> {
                new FootballTeam(playerNames[0][0], 0, teamNames[0])
            };

            //Initialisation elements of the list with type FootballTeam
            for (int i = 1; i < 6; i++)
            {
                TeamsValue.Add(new FootballTeam(playerNames[i][0], 0, teamNames[i]));
            }

            ////Initialisation of every footballer in list of teams
            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    TeamsValue[i].AddFootballer(new Footballer(playerNames[i][j + 1], 0));
                }
            }

            //creating object Championship champ and initialising it with objects of FootballTeam
            Championship Champ = new Championship(TeamsValue[0]);

            for (int i = 1; i < 6; i++)
            {
                Champ.AddTeam(TeamsValue[i]);
            }


            int  numberOfSeasons = 0;
            bool flag            = false;

            while (!flag)
            {
                Console.Write("Enter number of championship seasons: ");
                flag = true;
                try
                {
                    numberOfSeasons = Convert.ToInt32(Console.ReadLine());
                    if (numberOfSeasons <= 0)
                    {
                        throw new Exception("Number of seasons can't be equal or less then 0");
                    }
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine($"\n Incorrect Input. Exception: {ex.Message} \n");
                    flag = false;
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"\n Incorrect Input. Exception: {ex.Message} \n");
                    flag = false;
                }
            }


            string[][] HistoryOfMatches = new string[numberOfSeasons][];
            string[][] buffer           = new string[numberOfSeasons][];

            for (int i = 0; i < numberOfSeasons; i++)
            {
                HistoryOfMatches[i] = new string[30];
            }

            for (int i = 0; i < numberOfSeasons; i++)
            {
                buffer[i] = Champ.PlayChampionship(Champ);
            }

            for (int i = 0; i < numberOfSeasons; i++)
            {
                for (int j = 0; j < 30; j++)
                {
                    HistoryOfMatches[i][j] = buffer[i][j];
                }
            }

            IPrintable Printer = new ConsoleOutput();


            for (int z = 0; z < 100; z++)
            {
                Console.WriteLine("\n\t Options of Menu:");
                Console.WriteLine("1. View teams' squads.");
                Console.WriteLine("2. Print statistic of the team in current season.");
                Console.WriteLine("3. Watch the match history of current season of the championship.");
                Console.WriteLine("4. Whatch match Announcement.");
                Console.WriteLine("5. Show championship Leaderbord.");
                Console.WriteLine("6. Show History of matches between two teams.");
                Console.WriteLine("0. Exit.");
                Console.Write("\n\tChoose an option: ");

                int UserDesire = 0;

                try
                {
                    UserDesire = Convert.ToInt32(Console.ReadLine());
                    if (UserDesire < 0 || UserDesire > 6)
                    {
                        throw new Exception("Your choise can't be less then 0 or grater then 6");
                    }
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine($"\n Incorrect Input. Exception: {ex.Message} \n");
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Incorrect input. Exception: {ex.Message} \n");
                }

                switch (UserDesire)
                {
                case 1:
                    Console.WriteLine();
                    Printer.PrintTeamsSquads(Champ);
                    break;

                case 2:

                    Console.Write("Enter NAME of the team, which statistic you wanna see: ");
                    string RequestedTeam = "";

                    try
                    {
                        RequestedTeam = Console.ReadLine();
                    }
                    catch (ArgumentException ex)
                    {
                        Console.WriteLine($"\n Incorrect Input. Exception: {ex.Message} \n");
                    }
                    Console.WriteLine();
                    Printer.PrintTeamStats(Champ, RequestedTeam);
                    break;

                case 3:
                    Console.WriteLine("\n\t Seasons");
                    for (int i = 0; i < numberOfSeasons; i++)
                    {
                        Console.WriteLine($"{i + 1}. Season number {i + 1}");
                    }
                    Console.Write("\n\tChoose a season: ");
                    int orderNumber = 0;

                    try
                    {
                        orderNumber = Convert.ToInt32(Console.ReadLine());
                        if (orderNumber <= 0 || orderNumber > numberOfSeasons)
                        {
                            throw new Exception("Incorrect input. The order number of championship to view can't be less then 0, and greater then amount of them.");
                        }
                    }
                    catch (ArgumentException ex)
                    {
                        Console.WriteLine($"\n Incorrect Input. Exception: {ex.Message} \n");
                        break;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"\n {ex.Message}");
                        break;
                    }
                    Console.WriteLine();
                    Printer.PrintMatchHistory(HistoryOfMatches[orderNumber - 1], orderNumber);
                    break;

                case 4:
                    string[] MatchesAnnouncement = new string[30];
                    int      matchCouner         = 0;
                    for (int i = 0; i < 6; i++)
                    {
                        for (int j = 0; j < 6; j++)
                        {
                            if (i != j)
                            {
                                MatchesAnnouncement[matchCouner] = $"{Champ.GetTeam(i).FootballTeamName} - {Champ.GetTeam(j).FootballTeamName}";
                                matchCouner++;
                            }
                        }
                    }
                    Console.WriteLine();
                    Printer.PrintMatchAnnouncement(MatchesAnnouncement);
                    break;

                case 5:
                    Console.WriteLine();
                    Printer.PrintLeaderBoard(Champ);
                    break;

                case 6:
                    Console.Write("Enter NAME of the first team: ");
                    string team1 = "";

                    try
                    {
                        team1 = Console.ReadLine();
                    }
                    catch (ArgumentException ex)
                    {
                        Console.WriteLine($"\n Incorrect Input. Exception: {ex.Message} \n");
                    }
                    Console.Write("Enter NAME of the second team: ");

                    string team2 = "";

                    try
                    {
                        team2 = Console.ReadLine();
                    }
                    catch (ArgumentException ex)
                    {
                        Console.WriteLine($"\n Incorrect Input. Exception: {ex.Message} \n");
                    }
                    Console.WriteLine();
                    Printer.ShowTwoTeamHistory(HistoryOfMatches, team1, team2, numberOfSeasons);
                    break;
                }
                if (UserDesire == 0)
                {
                    break;
                }
            }
            Console.ReadKey();
        }