Skip to content

Instantly share code, notes, and snippets.

@ThiagoBarradas
Last active January 24, 2021 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThiagoBarradas/3bc8f138646348263d85373578b249b2 to your computer and use it in GitHub Desktop.
Save ThiagoBarradas/3bc8f138646348263d85373578b249b2 to your computer and use it in GitHub Desktop.
SOLID [L] - Correct Implementation
public abstract class Transaction
{
public long OriginalAmount { get; set; }
public virtual long GetTotalPaid()
{
return this.OriginalAmount;
}
}
public class CreditCardTransaction : Transaction
{
public long InterestAmount { get; set; }
public override long GetTotalPaid()
{
return this.OriginalAmount + this.InterestAmount;
}
}
public class PixTransaction : Transaction
{
}
// class that needs transacion
public class Order
{
// ctor and some properties
public long TotalPaid { get; private set; }
public void AddTransaction(Transaction transaction)
{
this.TotalPaid += transaction.GetTotalPaid();
// do something more
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment