class HappyBirthday { //==================== // CLASS VARIABLES //==================== private int numberOfPresents; private string birthdayMessage; private bool birthdayParty; //=========================== // DEFAULT CONSTRUCTOR //=========================== public HappyBirthday() { numberOfPresents = 0; birthdayParty = false; } //=========================== // METHOD //=========================== private string getMessage(string givenName) { string theMessage; theMessage = "Happy Birthday " + givenName + "\n"; theMessage += "Number of presents = "; theMessage += numberOfPresents.ToString() + "\n"; if (birthdayParty == true) { theMessage += "Hope you enjoy the party!"; } else { theMessage += "No party = sorry!"; } return theMessage; } //================================ // READ AND WRITE PROPERTY //================================ public string MyProperty { get { return birthdayMessage; } set { birthdayMessage = getMessage(value); } } //================================ // WRITE-ONLY PROPERTY //================================ public int PresentCount { set { numberOfPresents = value; } } public bool hasParty { set { birthdayParty = value; } } }