when you are asking a question, you need to post the error which you are getting with your code, so that we can solve it easily
any way i have posted my code which i have tested with your code
replace your code with below code
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
BirthdayParty partyOn = new BirthdayParty();
MessageBox.Show( partyOn.getMessage("Shadid"));
MessageBox.Show( partyOn.getPresents(8) );
MessageBox.Show( partyOn.getParty( true) );
}
}
class HappyBirthday
{
private string birthdayMessage;
private string presentString;
public HappyBirthday()
{
presentString = "Number of presents: ";
birthdayMessage = "Happy Birthday";
}
public string getMessage(string givenName)
{
return birthdayMessage + givenName;
}
public string getPresents(int numPresents)
{
presentString = presentString + numPresents.ToString();
return presentString;
}
}
class BirthdayParty : HappyBirthday
{
public BirthdayParty() : base()
{
}
public string getParty (bool haveParty)
{
if (haveParty == true)
{
return "Enjoy your party!";
}
else
{
return "Sorry – No party for you!";
}
}
}