Skip to content

Branches - Macaria #32

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Branches - Macaria #32

wants to merge 2 commits into from

Conversation

mdove92
Copy link

@mdove92 mdove92 commented Aug 7, 2019

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? Keeping my acceptable operator inputs in one array helped keep user input validation organized. My variables are all appropriately names and distinct enough from one another to not confuse readers. Rufo helped me with indentation!
How did your code keep track of user input? I kept my user input in the variables operator, which is later changed to operator_select through my case syntax. operand1 and operand2 held the number inputs from the user and are received through the get_operand method.
How did your code determine what operation to perform? The case syntax converted the user input from a string to a symbol, which allowed me to use it in a calculation in combination with the two received operands.
What opportunities exist to create small methods for this project? I could create a method for the output of the final equation, and create a method for the calculation solution.
In the next project, what would you change about your process? What would you keep doing? For the next project I would like to create more full pseudocode to get my ideas generating instead of refactoring already written code as I find more efficient solutions along the way. I would like to keep practicing writing methods to make more concise code.

@tildeee
Copy link
Collaborator

tildeee commented Aug 9, 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

Macaria, this project submission is wonderful! It's very well-organized, thoughtful, logical, and readable. I'm particularly excited about your get_operand method.

I have a few comments and suggestions on a few places of refactoring if you had more time on this project.

Well done on your solution overall! Great work!

@@ -0,0 +1,66 @@
operand = ()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need this variable to be defined outside of the method?

@@ -0,0 +1,66 @@
operand = ()
Copy link
Collaborator

Choose a reason for hiding this comment

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

As a separate note, if operand was something we needed, instead of (), it may be good to give operand a default value, or set it to nil. Maybe something like operand = 0 or operand = nil, just like you did with operator_select

Exponify(**)

Please select an operator"
operator = gets.chomp.to_s.downcase
Copy link
Collaborator

Choose a reason for hiding this comment

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

Because you mentioned that you would like to make more methods, and also because your get_operand method was really nice, I may suggest making a get_operator method. Even if a method to get the operator is used once, the benefits of the organization can be worth it!

puts "What is your second number?"
operand2 = get_operand()

# Validate that the user is not trying to divide by 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good style and frequency of comments throughout the whole submission!


# Output equation and solution
puts "Let's do this math!"
puts "#{operand1} #{operator_select} #{operand2} = #{operand1.to_f.public_send(operator_select, operand2.to_f)}"
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 with using public_send! It ends up being a great solution for this assignment. In future projects and assignments, it'll be really dangerous and weird for us to use public_send, so I'm just calling out right now that I don't expect to use this basically ever again. :P

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