Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement equality for Dollar #3

Merged
merged 3 commits into from
Sep 28, 2022
Merged

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.

None yet

1 participant