Last active
January 24, 2021 15:58
-
-
Save ThiagoBarradas/3bc8f138646348263d85373578b249b2 to your computer and use it in GitHub Desktop.
SOLID [L] - Correct Implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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