Beispiel #1
0
//   this method has a new parameter of paramaplant, different than plantrameter because its a new method. however both are plant objects. when we call each of these method both will take in the argument myPlant.
    public static void PromptUser(Plant paramaPlant)
    {
        Console.WriteLine("To water your plant, press 'w'; to sun your plant, press 's', to show your plant's description, press 'd'");
        string userAnswer = Console.ReadLine();

        if (userAnswer.ToLower() == "w" || userAnswer.ToLower() == "water")
        {
            paramaPlant.Water();
            if (paramaPlant.Height % 3 == 0)
            {
                paramaPlant.AddFlower();
                Console.WriteLine(paramaPlant.printFlowers());
            }
            Console.WriteLine("You watered your plant! Your plant's new height is " + paramaPlant.Height);
            PromptUser(paramaPlant);
        }
        else if (userAnswer.ToLower() == "s" || userAnswer.ToLower() == "sun")
        {
            string health = paramaPlant.GiveSunshine();
            Console.WriteLine("You sunned your plant! Your plant's new health is " + health);
            PromptUser(paramaPlant);
        }
        else if (userAnswer.ToLower() == "d" || userAnswer.ToLower() == "description")
        {
            ShowPlantStats(paramaPlant);
            PromptUser(paramaPlant);
        }
        else
        {
            Console.WriteLine("Nice try! Go plant yourself!");
            PromptUser(paramaPlant);
        }
    }