Ejemplo n.º 1
0
    public static void Main()
    {
        Octopus o = new Octopus();

        if (o.isHungry())
        {
            Console.WriteLine("The octopus is hungry!\n");
        }
        else
        {
            Console.WriteLine("The octopus isn't hungry!\n");
        }

        o.Digest(75);
        Console.WriteLine("The octopus is {0}% hungry", o.HungerPercent);
        Console.WriteLine("Feeding the octopus with an int...");
        o.Eat(10);
        Console.WriteLine("The octopus is {0}% hungry", o.HungerPercent);
        Console.WriteLine("Feeding the octopus with a string...");
        o.Eat("10");
        Console.WriteLine("The octopus is {0}% hungry", o.HungerPercent);
    }
    public static void Main()
    {
        Octopus o = new Octopus();

        o.name = "Fred";

        Console.WriteLine("The octopus {0} hungry!\n", o.isHungry() ? "is" : "isn't");

        Console.WriteLine("Digesting 75 food!");
        o.Digest(75);
        Console.WriteLine("The octopus is {0}% hungry\n", o.HungerPercent);

        Console.WriteLine("Feeding the octopus with an int...");
        o.Eat(10);
        Console.WriteLine("The octopus is {0}% hungry\n", o.HungerPercent);

        Console.WriteLine("Feeding the octopus with a string...");
        o.Eat("10");
        Console.WriteLine("The octopus is {0}% hungry\n", o.HungerPercent);

        Console.WriteLine("The octopus is named: {0}", o.name);
        Console.WriteLine("The octopus is age: {0}", o.age);
        Console.WriteLine("The octopus has {0} legs and {1} eyes!", Octopus.legs, Octopus.eyes);
    }