Created
March 24, 2020 14:20
-
-
Save MufidJamaluddin/7736242b9d9f36ec5688b89c49558694 to your computer and use it in GitHub Desktop.
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 MogeInvoice : Invoice | |
| { | |
| public MogeInvoice(Motorcycle motor, Duration duration) : base(Motorcycle motor, Duration duration) | |
| { | |
| } | |
| public override Double CalculateInvoice() | |
| { | |
| // perhitungan invoice Moge | |
| } | |
| } | |
| public static class InvoiceFactory | |
| { | |
| public static Invoice Create(Motorcycle motor, Duration duration) | |
| { | |
| return motor.type switch { | |
| "rent" => return new RentInvoice(motor, duration), | |
| "loan" => return new LoanInvoice(motor, duration), | |
| "personal" => return new PersonalInvoice(motor, duration), | |
| // tambah disini! | |
| "moge" => return new MogeInvoice(motor, duration), | |
| _ => throw new Exception("Motorcycle type is invalid!"), | |
| }; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment