コード例 #1
0
        public override bool Equals(object obj)
        {
            if (obj.GetType() != this.GetType())
            {
                return(false);
            }

            IDontLike person = (IDontLike)obj;

            return(this.name == person.name);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: DiLazania/sharpsharpsharp
        public static void IDontLikeFunc()
        {
            Console.WriteLine("I dont have any unloved teams. Maybe you have?\n Yes or 1/No or 2");
            string command = Console.ReadLine();

            command = command.ToUpper();
            IDontLike team = new IDontLike();

            if ((command == "YES") || (command == "1"))
            {
                Console.WriteLine("Soo, choose the team name, hater\n1: Akcio\n2: Ezji\n3: Reticolo\n4: Sherpei\n5: Reshetochki");
                int sel = int.Parse(Console.ReadLine());
                switch (sel)
                {
                case 1:
                    team.name = "Akcio";
                    Console.WriteLine("Good choice\n");
                    break;

                case 2:
                    team.name = "Ezji";
                    Console.WriteLine("Good choice\n");
                    break;

                case 3:
                    team.name = "Reticolo";
                    Console.WriteLine("Good choice\n");
                    break;

                case 4:
                    team.name = "Sharpei";
                    Console.WriteLine("Good choice\n");
                    break;

                case 5:
                    team.name = "Resheochki";
                    Console.WriteLine("Oh noo(((");
                    break;

                default:
                    Console.WriteLine("Okey, just nobody");
                    team.name = "Nobody";
                    break;
                }
            }
            if ((command == "NO") || (command == "2"))
            {
                Console.WriteLine("Hmmmmm, okey\n");
                team.name = "Nobody";
            }
            object ThisTeam = new IDontLike()
            {
                name = "Nobody"
            };

            Console.WriteLine($"ToString:  {team.ToString()} \n");

            Console.Write("Equals: ");
            if (team.Equals(ThisTeam))
            {
                Console.WriteLine("Ohhhh, nice. You love everyone, because you chose 2 higher\n");
            }
            else
            {
                Console.WriteLine("Hater\n");
            }

            Console.WriteLine(team.GetHashCode());
            Console.ReadKey();
        }