Hello friends,
I have a Customer class (Parent class) and Member class (child class which extends Customer class).
the coding is like this
public class Customer
{
String name;
}
public class Member extends Customer
{
int memberID;
}
public class Tranasaction
{
public void printTransaction(Customer customer)
{
if(customer.memberID exists)
{
give discount;
}
}
}
//another thought ----
public class Tranasaction
{
public void printTransaction(Member customer)
{
if(customer.memberID exists)
{
give discount;
}
}
}
when i use first way, compiler is throwing error as usual Customer object is not aware of Member class details.
When i use second way, Compiler is fine but during run time when i pass Customer object as an argument against Member type, Its throwing error.
So how do i handle same printTransaction for both customers