Skip to content

Conversation

@kaiosilveira
Copy link
Owner

As our code is written in Typescript instead of Java, equality works a bit different. There's no equals method to override in subclasses, so what I've done here was actually implementing a equals method that receives a dollar object and casts it to a Dollar, finally comparing their amounts to see if there's a match. The function satisfies the equality logic approached by the book and brings, in the same way, two new concerns to our task list: checking equality when the input is null and when the input is another object. Our current tasklist is:

  • $5 + 10CHF = $10 if rate is 2:1 🎯
  • $5 * 2 = $10 ✅
  • Make "amount" private
  • Dollar side-effects? ✅
  • Money rounding?
  • equals() ✅
  • Equal null
  • Equal object

Tasklist:
- $5 + 10CHF = $10 if rate is 2:1 🎯
- $5 * 2 = $10 ✅
- Make "amount" private
- Dollar side-effects? ✅
- Money rounding?
- equals() 👈🏼
Tasklist:
- $5 + 10CHF = $10 if rate is 2:1 🎯
- $5 * 2 = $10 ✅
- Make "amount" private
- Dollar side-effects? ✅
- Money rounding?
- equals() 👈🏼
Tasklist:
- $5 + 10CHF = $10 if rate is 2:1 🎯
- $5 * 2 = $10 ✅
- Make "amount" private
- Dollar side-effects? ✅
- Money rounding?
- equals() ✅
- Equal null
- Equal object
@kaiosilveira kaiosilveira merged commit 07a740a into main Sep 28, 2022
@kaiosilveira kaiosilveira deleted the chapter3/dollar-equality branch September 28, 2022 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants