This file contains hidden or 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 interface ITalkative | |
{ | |
void Speak(string message); | |
} | |
public interface IMovable | |
{ | |
void Move(long x, long y, long z); | |
} |
This file contains hidden or 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 interface IMovable | |
{ | |
void Move(long x, long y, long z); | |
} | |
public interface IHuman : IMovable | |
{ | |
string Name { get; set; } | |
string Document { get; set; } |
This file contains hidden or 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 interface IHuman | |
{ | |
string Name { get; set; } | |
string Document { get; set; } | |
long Age { get; set; } | |
void Move(long x, long y, long z); | |
This file contains hidden or 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 class Transaction | |
{ | |
public virtual long OriginalAmount { get; set; } | |
public virtual long InterestAmount { get; set; } | |
} | |
public class CreditCardTransaction : Transaction | |
{ | |
} |
This file contains hidden or 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; | |
} | |
} |
This file contains hidden or 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 class CreditCardTransaction : Transaction | |
{ | |
public long InterestAmount { get; set; } | |
} |
This file contains hidden or 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
// sample enum for payment.Type | |
public enum PaymentType | |
{ | |
CreditCard, | |
DebitCard, | |
BankInvoice, | |
Pix | |
} | |
// simple factory |
This file contains hidden or 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 class PaymentService | |
{ | |
public Payment ProcessPayment(Payment payment) | |
{ | |
if (payment.Type == "credit_card") | |
{ | |
// proccess payment with credit card | |
} | |
else if (payment.Type == "debit_card") | |
{ |
This file contains hidden or 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 class PaymentService : IPaymentService | |
{ | |
private readonly IPaymentRepository PaymentRepository; | |
private readonly INotificationService NotificationService; | |
private readonly IBankService BankService; | |
public PaymentService( | |
IPaymentRepository paymentRepository, |
This file contains hidden or 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 class PaymentService | |
{ | |
// ctors | |
// properties | |
// etc | |
public Payment ProcessPayment(Payment payment) | |
{ | |
var transaction = this.BankService.CreateTransaction(payment); |