Skip to content

Instantly share code, notes, and snippets.

@soheil-moonesi
Created February 4, 2024 08:36
Show Gist options
  • Select an option

  • Save soheil-moonesi/11e99c1f4bd2df201de2fb01b97361d5 to your computer and use it in GitHub Desktop.

Select an option

Save soheil-moonesi/11e99c1f4bd2df201de2fb01b97361d5 to your computer and use it in GitHub Desktop.
// Without inheritance
public class SavingsAccount
{
private double balance;
public double GetBalance()
{
return this.balance;
}
}
public class CurrentAccount
{
private double balance;
public double GetBalance()
{
return this.balance;
}
}
// With inheritance
public class Account
{
protected double balance;
public double GetBalance()
{
return this.balance;
}
}
public class SavingsAccount : Account
{
// Other specific methods and properties
}
public class CurrentAccount : Account
{
// Other specific methods and properties
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment