コード例 #1
0
ファイル: Program.cs プロジェクト: 1is0/Slizh
 static void Main(string[] args)
 {
     Footballer first = new Footballer();
     Footballer second = new Footballer("Rooney","Wayne","England", new DateTime(1985, 10, 24),80,176,Position.CentralForward,91,65000000);
     var third = EnterPlayer();
     Console.WriteLine(first);
     Console.WriteLine(second);
     Console.WriteLine(third);
     Footballer[] arr = new Footballer[2];
     MakingArrayOfFootbalists(arr);
 }
コード例 #2
0
        public static Footballer EnterPlayer()
        {
            Console.WriteLine("Creating of a new player");
            Footballer player = new Footballer();

            Console.WriteLine("Enter surname:");
            player.Surname = Console.ReadLine();
            Console.WriteLine("Enter name:");
            player.Name = Console.ReadLine();
            Console.WriteLine("Enter country:");
            player.Country = Console.ReadLine();
            Console.WriteLine("Enter date of birth:");
            //DateTime date = CheckDate();
            player.DateOfBirth = CheckDate();
            Console.WriteLine("Enter Weight[20,300]:");
            player.Weight = CheckOfWeight();
            Console.WriteLine("Enter Height:");
            player.Height = CheckNaturalNumber();
            Console.WriteLine("Enter a salary of footballer:");
            player.Salary = CheckNaturalNumber();
            OutputOfEnum();
            player.Position = (Position)CheckPosition();
            Console.WriteLine("Enter FIFA rating[45,89]:");
            player.qual.fifaRate = CheckFifaRating();
            Console.WriteLine("Enter maximal coast of player:");
            player.qual.maxCoast = CheckNaturalNumber();
            Console.WriteLine("Do u want to send a footballer on carantine?\n1 - Yes\t0 - No\n(salary -70%)");
            int temp = YesNoCheck();

            if (temp == 1)
            {
                player.Carantine(player.Salary);
            }
            Console.WriteLine("Do u want to give a nickname for a footballer?\n1 - Yes\t0 - No");
            int nick = YesNoCheck();

            if (nick == 1)
            {
                Console.WriteLine("Enter a nickname of footballer(name and surname will be changed)");
                player.Nickname();
                return(player);
            }
            else
            {
                return(player);
            }


            //return new Footballer(surname, name, country, date, weight, height, salary, (Position)position, fifaRate, coast);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: 1is0/Slizh
        /*  static void Coping()
         * {
         *    Console.WriteLine("Enter which player do u want to copy:");
         *    int cpy = Convert.ToInt32(Console.ReadLine());
         *    if ()
         * }*/
        static void Main(string[] args)
        {
            bool       flag   = false;
            Footballer first  = new Footballer();
            Footballer second = new Footballer("Rooney", "Wayne", "England", new DateTime(1985, 10, 24), 80, 176, 100000, Position.CentralForward, 91, 65000000);
            var        third  = EnterPlayer();

            Console.Clear();
            Console.WriteLine(first);
            Console.WriteLine(second);
            Console.WriteLine(third);
            Console.WriteLine("=>Press enter");
            Console.ReadLine();
            Console.Clear();
            Footballer[] arr = new Footballer[2];
            MakingArrayOfFootbalists(arr);
            Console.WriteLine("=>Press enter");
            Console.ReadLine();
            Console.Beep();
            Console.Clear();
            while (flag != true)
            {
                Console.WriteLine("Enter which player do u want to copy:");
                int cpy = Convert.ToInt32(Console.ReadLine());
                if (cpy < arr.Length + 1)
                {
                    Footballer player = (Footballer)arr[cpy - 1].Clone();
                    Console.WriteLine("Copied player:");
                    Console.WriteLine(player);
                    flag = true;
                }
                else
                {
                    Console.WriteLine("Player not exists, Enter existing player!");
                }
            }
            Console.WriteLine("=>Press enter");
            Console.ReadLine();
            Console.Clear();
            Console.Beep();
            Console.WriteLine("Array of footballers, sorted by coast, using IComparer");
            Array.Sort(arr, new Footballer());
            foreach (Footballer f in arr)
            {
                Console.WriteLine(f);
            }
            Console.WriteLine("=>Press enter");
            Console.ReadLine();
        }
コード例 #4
0
        /*  static void Coping()
         * {
         *    Console.WriteLine("Enter which player do u want to copy:");
         *    int cpy = Convert.ToInt32(Console.ReadLine());
         *    if ()
         * }*/
        static void Main(string[] args)
        {
            bool       flag   = false;
            Footballer first  = new Footballer();
            Footballer second = new Footballer("Rooney", "Wayne", "England", new DateTime(1985, 10, 24), 80, 176, 100000, Position.CentralForward, 91, 65000000);
            var        third  = EnterPlayer();

            Console.Clear();
            Console.WriteLine(first);
            Console.WriteLine(second);
            Console.WriteLine(third);
            Console.WriteLine("=>Press enter");
            Console.ReadLine();
            Console.Clear();
            Footballer[] arr = new Footballer[2];
            MakingArrayOfFootbalists(arr);
            Console.WriteLine("=>Press enter");
            Console.ReadLine();
            Console.Beep();
            Console.Clear();
            while (flag != true)
            {
                Console.WriteLine("Enter which player do u want to copy:");
                int cpy = Convert.ToInt32(Console.ReadLine());
                if (cpy < arr.Length + 1)
                {
                    Footballer player = (Footballer)arr[cpy - 1].Clone();
                    Console.WriteLine("Copied player:");
                    Console.WriteLine(player);
                    flag = true;
                }
                else
                {
                    Console.WriteLine("Player not exists, Enter existing player!");
                }
            }
            Console.WriteLine("=>Press enter");
            Console.ReadLine();
            Console.Clear();
            Console.Beep();
            Console.WriteLine("Array of footballers, sorted by coast, using IComparer");
            Array.Sort(arr, new Footballer());
            foreach (Footballer f in arr)
            {
                Console.WriteLine(f);
            }
            Console.WriteLine("=>Press enter");
            Console.Clear();
            Console.WriteLine("Do you want to train your footballers?");
            Console.WriteLine("1-Yes, 0-No");
            int tmp = YesNoCheck();

            if (tmp == 1)
            {
                Console.WriteLine("Choose the footballer who you want to train.");
                int foot = Convert.ToInt32(Console.ReadLine());
                arr[foot - 1].EndWork += delegate
                {
                    Console.WriteLine("Now your fifa rating" + arr[foot - 1].qual.fifaRate);
                    Console.WriteLine("Now your weight " + arr[foot - 1].Weight);
                };
                arr[foot - 1].Training();

                Console.WriteLine();
            }
            Console.WriteLine("Do u want to train another player");
            Console.WriteLine("1-yes 0-no");
            tmp = YesNoCheck();
            if (tmp == 1)
            {
                Console.WriteLine("Choose the footballer who you want to train.");
                int foot = Convert.ToInt32(Console.ReadLine());
                try
                {
                    arr[foot - 1].EndWork += () =>
                    {
                        Console.WriteLine("Now your fifa rating" + arr[foot - 1].qual.fifaRate);
                        Console.WriteLine("Now your weight " + arr[foot - 1].Weight);
                    };
                    arr[foot - 1].Training();
                }
                catch (IndexOutOfRangeException)
                {
                    Console.WriteLine("Incorrect choosing of player");
                }
            }

            Console.ReadLine();
        }