is inaccessible due to its protection level

In your base class Clubs the following are declared protected

  • club;
  • distance;
  • cleanclub;
  • scores;
  • par;
  • hole;

which means these can only be accessed by the class itself or any class which derives from Clubs.

In your main code, you try to access these outside of the class itself. eg:

Console.WriteLine("How far to the hole?");
myClub.distance = Console.ReadLine();

You have (somewhat correctly) provided public accessors to these variables. eg:

public string mydistance
{
    get
    {
        return distance;
    }
    set
    {
        distance = value;
    }
}        

which means your main code could be changed to

Console.WriteLine("How far to the hole?");
myClub.mydistance = Console.ReadLine();

Leave a Comment