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 Invoice { | |
| private bool isForXDepartment; // ตัดทิ้งได้ | |
| private bool isForYDepartment; // ตัดทิ้งได้ | |
| private bool isCalculateVat; | |
| private bool isCalculateSpecialTax; | |
| private List<InvoiceItem> items; | |
| public class InvoiceItem { | |
| public int quantity; |
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 InvoiceDepartmentY { | |
| private bool isCalculateSpecialTax; | |
| private List<InvoiceItem> items; | |
| public class InvoiceItem { | |
| public int quantity; | |
| public string description; | |
| public double pricePerUnit; | |
| } |
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 InvoiceNormal { | |
| private bool isCalculateSpecialTax; | |
| private List<InvoiceItem> items; | |
| public class InvoiceItem { | |
| public int quantity; | |
| public string description; | |
| public double pricePerUnit; | |
| } |
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 InvoiceDepartmentX { | |
| private List<InvoiceItem> items; | |
| public class InvoiceItem { | |
| public int quantity; | |
| public string description; | |
| public double pricePerUnit; | |
| } |
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 Invoice { | |
| private ISumpriceCalculator sumpriceCalculator; | |
| private List<InvoiceItem> items; | |
| public class InvoiceItem { | |
| public int quantity; | |
| public string description; | |
| public double pricePerUnit; | |
| } |
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 ISumpriceCalculator { | |
| double calculateSumPrice(List<InvoiceItem> items); | |
| double plusVat(double price); | |
| } | |
| public class DepartmentXSumpriceCalculator: ISumpriceCalculator { | |
| public double calculateSumPrice(List<InvoiceItem> items) { | |
| return items.sum(d => d.pricePerUnit); | |
| } |
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
| var calculator = SumpriceCalculatorFactory.createSumpriceCalculator(Department.X, false); | |
| var invoice = new Invoice(calculator); |
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 double calculateSumPrice () { | |
| var price = 0.0; | |
| price = calculateSumPrice(); // แต่ calculcateSumPrice อาจจะทำงานไม่เหมือนกันขึ้นอยู่กับว่า Inject อะไรเข้ามา | |
| price = plusVat(price); // เช่นกัน plusVat เราก็ไม่อยากให้ทำงานเหมือนกัน | |
| return price; | |
| } |
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
| const getPlayerRankingsRepositories = () => { | |
| rankingEntryRepository, | |
| tokenValidator, | |
| ...getPlayersUserRepositories() | |
| } | |
| const getPlayersUserRepositories = () => { | |
| playerRepository, | |
| legacyUserRepository | |
| } |
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
| (ns todomvc.state | |
| (:require [reagent.core :as r] | |
| [cljs-uuid-utils.core :as uuid])) | |
| (defonce todo-data (r/atom (array-map))) | |
| (defn add [title] | |
| (let [new-uuid (uuid/uuid-string (uuid/make-random-uuid))] | |
| (swap! todo-data assoc new-uuid {:id new-uuid | |
| :title title |