Skip to content

Commit

Permalink
♻️ 【第4章 意図を語るテスト】よりイミュターブルな形にするため amout を private にする
Browse files Browse the repository at this point in the history
・public から private に返ることでインスタンスを作るたび amout が作られるようにする
・外から改変できないような形にするため
・amount フィールドを使う人が dollar クラスだけになったので外から呼ぶ必要がなくなったため変更
  • Loading branch information
dodonki1223 committed Dec 12, 2021
1 parent a7096e0 commit 9add075
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- [ ] $5 + 10 CHF = $10(レートが 2:1 の場合)
- [x] $5 * 2 = $10
- [ ] amount を private にする
- [x] amount を private にする
- [x] Dollar の副作用どうする?
- [ ] Money の丸め処理どうする?
- [x] nullとの等価性比較
Expand Down
2 changes: 1 addition & 1 deletion src/dollar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export class Dollar {
constructor(public amount: number) {
constructor(private readonly amount: number) {
this.amount = amount
}

Expand Down

0 comments on commit 9add075

Please sign in to comment.