2016-10-09 12 views
-3
namespace HelloDogs 

{ クラス犬 { プライベート文字列をbarkSound作成したクラスから静的呼び出しありません。 プライベートストリングブリード; // dogHeight、dogColor、noOfLegsを
に追加しました private int dogHeight; //プライベート変数 プライベート文字列dogColor; プライベートstatic int noOfLegs;は、どのように私はC#で

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

    public static int NoOfLegs 
    { 
    get{return noOfLegs; }  // I created properties to encapsulate the variables 
     set {noOfLegs = value; } // dogHeight, dogColor and noOfLegs using the properties 
    } 

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

    public string DogColor 
    { 
     get {return dogColor;} 
     set{ dogColor = value;} 
    } 

    private string dogSpeech; 

    public Dog() 
    { 
     barkSound = "Jack!"; 
     breed = "cocker spaniel"; 
    } 
    // Added a new constructor below that takes the following parameters 
    public Dog(int h,string b, string c) 
    { 

     dogHeight = h; 
     dogColor = c; 
     breed = b; 
    } 
    // A private method to check the dogHeight if true or false 
    private bool IsBig(int x) 
    { 
     if (x < 50) 
      return false; 
     else 
      return true; 
    } 

//クラスから静的呼び出し
{

 dogSpeech = "Hello, I am a " + breed + " , " + dogHeight + "cm" + "," 
      + dogColor + "." + barkSound ; 
     return dogSpeech; 

     if(IsBig(dogHeight)) 
     { 
      return dogSpeech = "You are big "; 
     } else 
     { 
      dogSpeech = " You are not big enough"; 
     } 
    } 
    public void SetSound(String barkSound) 
    { 
     this.barkSound = barkSound; 

    } 


} 

}

+1

コードダンプは良い質問をしません。助けを得るために、小さな例を作り、非常に具体的な質問をしてください。 – dasblinkenlight

+0

よろしくお願いします。次回は非常に具体的になります。 – kelvin

答えて