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

Create Pipes - Nkiru- Calculator.rb #44

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

Conversation

nkiruka
Copy link

@nkiruka nkiruka commented Aug 11, 2017

Calculator

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
Describe how you stored user input in your program. I created variables for each number and result. In hindsight, I should have created a variable for the operation (this will be useful when printing out the result.
How did you determine what operation to perform? I used a case statement and a while loop. However, once the user selects operation to run, it breaks out of the loop (which was my intent). However, I wonder if there is a more efficient way to do so.
How did you make sure your program behaved correctly? By invoking each method and running tests in irb.
Do you feel like you used consistent indentation throughout your code? I tried
If you had more time, what would you have added to or changed about the program? Yes, I spent a lot of time debugging one particular problem and probably should have moved to work on other parts of the code.

@droberts-sea
Copy link
Collaborator

Calculator

What We're Looking For

Feature Feedback
Takes in two numbers and an operator and performs the mathematical operation. Yes
Baseline
Readable code with consistent indentation. Mostly - see inline comments.

Great work overall!

if num.include?(".")
return num = Float(num)
else
return num = Integer(num)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Watch your spacing here - the else should be at the same level as the if above, and the return on line 50 should be indented more. When in doubt, use Atom's auto-indent.


# Methods for computing math operations
def add(num_1, num_2)
result = num_1 + num_2
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like that each of these is its own method. It makes it easy to find where in the code a certain operation occurs, and means that if you need to add a long complex operation (think finding the least common multiple of 2 numbers) the pattern will still work.

@nkiruka nkiruka changed the title Create Pipes - <Nkiru> - <Calculator.rb> Create Pipes - Nkiru- Calculator.rb Nov 12, 2017
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