i have 3 classes: class PassengerDetails which is inherited by class FlightDetails which in turn is inherited by class Details. Both, PassengerDetails and FlightDetails have a method Accept which accepts some parameters and assigns it to local variables (declared as protected) of that class. What i need to do is by using a method Show in Details i want to print the values of those local variables of class PassengerDetails and FlightDetails. here are few parts of my entire code:
class PassengerDetails
{
protected string strFirstName;
protected int iAge;
public void Accept(string FirstName, int Age)
{
strFirstName = FirstName;
iAge = Age;
}
}
class FlightDetails:PassengerDetails
{
protected DateTime dt;
protected int iNumPass;
public void Accept_1(DateTime date,int NumPass)
{
dt = date;
iNumPass = NumPass;
}
}
class Details : FlightDetails
{
public void Show(Label lbl)
{
lbl.Text= "" + strFirstName +"\n"+ iAge +"\n"+ dt.ToString() + "\n"+ iNumPass;
}
private void btnSubmit_Click(object sender, EventArgs e)
{
PassengerDetails pass = new PassengerDetails();
pass.Accept(txtFName.Text,Convert.ToInt32(txtAge.Text));
}
private void btn2Submit_Click(object sender, EventArgs e)
{
FlightDetails fgt = new FlightDetails();
fgt.Accept_1(Convert.ToDateTime(dtDep.Text),Convert.ToInt32(txtNPass.Text));
Details det = new Details();
det.Show(lblShow);
when i do this, all i get is default value of those local variables. can someone plzz help???