Leaves - Yasmin#50
Conversation
beccaelenzil
left a comment
There was a problem hiding this comment.
Great work on this project. The feature that allows you to complete more than one problem is particularly nice. This is a great use of methods and iteration. Make sure you are answering the reflection questions thoroughly so that you are fully reflecting on your process. If it is easier to have a conversation than write these down, please let me know. Review the comments in the code review for a few more suggestions.
| print "How many operations would you like to do?: " | ||
| operator_num = gets.chomp | ||
|
|
||
| while operator_num !~ /^-?[0-9]+$/ |
There was a problem hiding this comment.
Make sure you cite your source if you found the regular expression somewhere.
| end | ||
| operator_num = operator_num.to_i | ||
|
|
||
| operator_num.times do |i| |
There was a problem hiding this comment.
This is a very nice feature. I enjoyed being able to complete multiple problems without rerunning the program!
| operator = gets.chomp | ||
| end | ||
| operator = operator | ||
| if operator_array.include?(operator) |
There was a problem hiding this comment.
You've written almost exactly the same code here twice, to get the first number and the second number. Could you DRY that up by putting this logic in a method and/or a loop?
| print "\nEnter your second number: " | ||
| num_2 = gets.chomp | ||
| end | ||
| num_2 = num_2.to_i |
There was a problem hiding this comment.
You should covert the number to a float rather than an integer so it handles division correctly (for instance, 5/6 should not equal 0).
| end | ||
| num_2 = num_2.to_i | ||
|
|
||
| if operator == "add" || operator == "+" |
There was a problem hiding this comment.
Consider using a case/when block to simplify your code.
CalculatorWhat We're Looking For
|
Calculator
Congratulations! You're submitting your assignment.
Comprehension Questions