Skip to content

Conversation

@kelsk
Copy link

@kelsk kelsk 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? My indentation and formatting is decent and improving. I feel like I can improve my variable naming and writing clear & concise comments.
How did your code keep track of user input? All the user input was assigned to variables.
How did your code determine what operation to perform? I used a "case" statement using the user-inputted operator selection to select the operation.
What opportunities exist to create small methods for this project? I could add a method to contain the code that asks for user input, so that I could potentially ask the user if they wanted to run the calculator, and then I could call the method depending on their answer.
In the next project, what would you change about your process? What would you keep doing? I backtracked a lot during my process because I did not thoroughly review the instructions before beginning to code. For future problems I will write pseudocode to understand the full scope of the problem before I begin coding. I do think I'm an excellent Googler and will keep googling answers to find solutions.

@tildeee
Copy link
Collaborator

tildeee commented Aug 9, 2019

Calculator

What We're Looking For

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

Great work on this project, Kelsey! The flavor of this project submission is ideal, honestly. Also, your code is great! The code is logical, readable, and well-organized. You did a lot of really clever things!

I have a couple comments that are mostly FYIs, with some minor ideas/suggestions.

That being said, the submission looks great; great work!


operands.each do |operand|
puts "#{operand[:id]}. #{operand[:name]} #{operand[:symbol]}"
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fancy!

puts "YOU HAVE CHOSEN EXPONENTIATION."
math_operand = :**
when "6", "MOD", "%"
puts "YOU HAVE CHOSEN MODULO-IFICATION. \n(CALCU-BOT DOES NOT KNOW THE VERB TENSE FOR A MODULO.)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

😂 😂 😂

def float_checker
self.to_f.to_s == self
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.

THIS IS COOL! And fancy! You are doing a thing which is adding a new method to the String class, which is what the user input it. We will definitely get into these details in a few weeks.

If you were curious about how to do this without working with the String class, I would likely make the methods integer_checker and float_checker not part of String, and define that it takes in a number, and replacing the self with that number, so:

def integer_checker(num)
  return num.to_i.to_s == num
end

Not a mandatory refactoring, but just wanted to give you this FYI!



# returns error message until user inputs an integer or float
def class_check(num)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor suggestion: I tend to really like having my method names read more like verbs. What is this method responsible for? It's used for checking what kind of number it is. There are a lot of different good names for this, but maybe I would name this check_valid_number_type or something like that

puts "CALCU-BOT CANNOT DIVIDE BY ZERO. ENTER ANOTHER NUMBER."
second_num = gets.chomp
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.

Nicely done!

puts "CALCU-BOT HAS CALCULATED THE CALCULATION."

def operate_numbers(symbol, num1, num2)
result = num1.public_send(symbol, num2)
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