Skip to content

Conversation

@tofuandeve
Copy link

Calculator

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
What went well in your code style, such as indentation, spacing, variable names, readability, etc.? What was lacking? I made smaller methods that I find I needed to use them more than once in my main() for better readability. I validated user inputs (operator, numbers, type of result user wants to see), handled some edge cases where user enters in silly input for example: enter "hello" for an operator input or numbers, or use 0 as a divisor, or use float as an exponent and print out proper errors on each case). There is some more simplification can be made.
How did your code keep track of user input? I used variables with proper naming to keep track of user input
How did your code determine what operation to perform? I created a method call calculator which takes in 2 numbers and an operator as arguments and used "case -when" to determine which operation to be made.
What opportunities exist to create small methods for this project? There are: getting numbers from user, getting operator from user, getting a type of result user wants to see, print the list of valid operators and the actual calculating part for each valid operator
In the next project, what would you change about your process? What would you keep doing? I would keep breaking down my problem to smaller sub-problems and make them methods if needed. I will need to work more on simplifying code for better organization and readability

@tofuandeve tofuandeve changed the title Calculator Assigmnent Submission Branches - Eve: Calculator Assigmnent Submission Aug 7, 2019
@tildeee
Copy link
Collaborator

tildeee commented Aug 10, 2019

Calculator

What We're Looking For

Feature Feedback
Readable code with consistent indentation x
Practices using variables appropriately x
Practices using conditionals appropriately x
If any, practices iteration appropriately x
If any, practices using custom methods appropriately x
Takes in two numbers and an operator and can perform addition x
Takes in two numbers and an operator and can perform subtraction x
The program handles divide when attempting to divide by zero x

Great work on this project, Eve! Your project submission is fantastic-- the code is extremely well-organized, logical, and readable. I can tell that a lot of thought went into how to organize and structure the code. Your methods are my favorite-- they are named as actions, they're descriptive and accurate, and they're meaningful. Your main method is a really great pattern :)

My only comments and suggestions are minor, because your logic and code style look great. We will go over some instructions on how to change your tab size to 2 spaces (rather than the default 4 spaces), but that's the only thing I want to call out right now.

Overall, great work on this!

puts "#{count}. #{key}(#{value})"
count += 1
end
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! I really like how you separated this functionality of printing the options with a method.

def get_a_number_from_user()
while true
input = gets.chomp
number = Float(input) rescue false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic solution! We'll get into details about rescue later in case you want to know more details about it, but this is a clever solution for this project

while true
input = gets.chomp
number = Float(input) rescue false
if number
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on using logic that relies on number evaluating to a truthy value!

return (operand1 / operand2)
when '^'
puts "Exponent can't be Float, your exponent was rounded down for this operation"
return (operand1 ** operand2.to_i)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good decision on how to handle this!

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