コード例 #1
0
        static void Main()
        {
            ForegroundColor = ConsoleColor.Red;
            Clear();
            WriteLine("\n Hamster will die soon..... OUH YEEEEEEŠŠŠŠŠŠŠŠŠ :D \n");
            ResetColor();
            ForegroundColor = ConsoleColor.White;

            Hamster hamster = new Hamster("Muki", 0, 0.2, 10);

            hamster.PrintHamsterInfo();
            hamster.EatingRunning();

            ForegroundColor = ConsoleColor.Red;
            WriteLine($"\n {hamster.name} has died at the age of {hamster.age} and at the weight of {Math.Round(hamster.weight, 2)}... HE IS DEAD, YEAAAAAAAH!!! VIIIIIIIIIIIIIIIIIIIII!!!!!!!!!!!!!");
            ForegroundColor = ConsoleColor.White;
            Write($"Hamster died of ");
            ForegroundColor = ConsoleColor.Red;
            WriteLine("STARVATION!!!");
            ForegroundColor = ConsoleColor.White;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Klaabut/Hamster-Homework
        static void Main(string[] args)
        {
            Hamster bob = new Hamster();

            bob.name     = "Bob";
            bob.age      = 0;
            bob.weight   = 0.7;
            bob.lifeSpan = 0;
            bob.ShowBobsInfo();
            for (bob.lifeSpan = 0; bob.lifeSpan < 10; bob.lifeSpan++)
            {
                if (bob.weight > 0.7)
                {
                    bob.Run();
                    bob.ShowBobsWeight();
                }

                bob.Eat();
                bob.ShowBobsWeight();
                bob.Age();
            }
            Console.WriteLine("The hamster dies");
            bob.ShowBobsInfo();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Hamster newPet = new Hamster("Pew");

            newPet.ShowPetData();
        }