Changing the GetOutput() Method so it returns details C# -


this sort of last resort kind of thing. given question on 1 of labs i'm having issues , can't sort out or understand i'm bad @ c#! anyway initial question is: in class dogchorus, change getoutput() method returns details of dogs created including number of legs dogs have. there hint 'you need call static nooflegs property created through class name. help/ tips can give me appreciated! code below both classes:

namespace hellodogs {     class dog     {         private string barksound;         private string breed;         private int dogheight;         private static int nooflegs;          public static int nooflegs         {             { return dog.nooflegs; }             set { dog.nooflegs = value; }         }          public int dogheight         {         { return dogheight; }         set { dogheight = value; }         }         private string dogcolour;          public string dogcolour         {         { return dogcolour; }         set { dogcolour = value; }         }          public string breed         {             { return breed; }             set { breed = value; }         }         private string dogspeech;          public dog()         {             barksound = "woof!";             breed = "cocker spaniel";             dogheight = 25;             dogcolour = " white";         }       private bool isbig (int y)         {             int dogheight = y;             if(dogheight <50)             {                 return false;             }             else             {                 return true;             }         }       public string getspeech(int thedog)      {          if (isbig(thedog))          {               dogspeech = "hello. " + breed + ". big.  " + "i " + dogheight + " cm high! " +              "my coat " + dogcolour + barksound;              return dogspeech;           }          else          {               dogspeech = "hello. " + breed + ". small. " + "i " + dogheight + " cm high! " +              "my coat " + dogcolour + barksound;              return dogspeech;          }      }          public void setsound(string barksound)         {             this.barksound = barksound;         }              public dog(int dogheight, string dogcolour, string breed)             {                 this.dogheight = dogheight;                 this.dogcolour = dogcolour;                 this.breed = breed;             }         }     }  namespace hellodogs {     class dogchorus     {         dog lady;         dog tramp;         dog griff;         dog lass;          public dogchorus()         {             lady = new dog();             tramp = new dog();             griff = new dog();             lass = new dog();             tramp.setsound("ruff!");             lass.setsound("howl!");         }          public string getoutput()         {             return dog.getspeech() + " \n " + dog.nooflegs() + " \n " + dog.getbreed();         }     } } 

you have line:

return dog.getspeech() + " \n " + dog.nooflegs() + " \n " + dog.getbreed(); 

although nooflegs static property, getspeech , breed not. (getbreed not declared anywhere). these 2 should accessed through instance, such lady.breed specific dog's data.

so, want access getspeech , breed calls each of instances. say: lady, tramp, griff, , lass.

also, nooflegs , breed properties, not methods, not put parenthesis @ end. dog.nooflegs or lady.breed.

also, getspeech() method needs re-writing. should not take parameters.

good luck.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -