0

Basically I have 2 classes (class Dog and class DogChorus) and i am trying to change the getoutput() because i want it to display a message box with a message telling the number of lesg that all dogs have and it should returns details of all dogs creat

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace HelloDogs
    {
        class DogChorus
        {
            Dog breed;
            Dog dogHeight;

            public DogChorus()
            {
                breed = new Dog();
                dogHeight = new Dog();
                dogHeight.SetSound("Ruff!");
            }

            public string GetOutput()
            {

                return dogHeight.dogSpeech() + " \n " + breed.dogSpeech();
            }

        }
    }

    2eme class:

       class Dog
        {
            private string barkSound;
            private string breed;
            private int dogHeight; 
            private string dogColour;
            private static int noOfLEgs;


            public string Breed
            {
                get { return breed; }
                set { breed = value; }
            }

            public int DogHeight
            {
                get { return dogHeight; } 
                set { dogHeight = value; } 
            }

            public string DogColour
            {
                get { return dogColour; } 
                set { dogColour = value; } 
            }

            public static int NoOfLEgs
            {
                get { return Dog.noOfLEgs; } 
                set { Dog.noOfLEgs = value; } 
            }

            private string dogSpeech;

            public Dog()
            {
                barkSound = "Woof!";
                breed = "cocker spaniel";
                dogHeight = 15;
                dogColour = " Brown";
            }

            private bool IsBig(int size)
            {
                bool Size1;

                if (size < 50)
                {
                    Size1 = false;
                }
                else
                {
                    Size1 = true;

                }
                return Size1;
            }


               public string GetSpeech(int theDog)
            {
                if (IsBig(theDog))
                {

      dogSpeech = "Hello. I am a " + breed + ". I am big and I mesure.  " + dogHeight + ". I am ." + dogColour + barkSound;
                    return dogSpeech;

             }
                else
                {
                    dogSpeech = "Hello. I am a " + breed + ". I am small. " + dogHeight + ". I am ." + dogColour + barkSound;
                    return dogSpeech;
                }
            }
            public void SetSound(String barkSound)
            {
                this.barkSound = barkSound;
            } 
        }
    }
2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by Codefiva
0

1.Set dogchors.goheight=20
2.Call getSpeech method.Remove the parameter of getspeech() method and isbig()

Reason:
as you already setting the value of dogheight,so when you call getspeech method then call will go to isbig() method,isbig will pick dogheight from dogheight porperty.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.