Skip to content

Leaves - Yasmin#50

Open
YasminM11 wants to merge 2 commits into
Ada-C12:masterfrom
YasminM11:master
Open

Leaves - Yasmin#50
YasminM11 wants to merge 2 commits into
Ada-C12:masterfrom
YasminM11:master

Conversation

@YasminM11
Copy link
Copy Markdown

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? In this code I used a clear variable names, spacing, and my code is easy to read.
How did your code keep track of user input? my code is Reading and checking user inputs
How did your code determine what operation to perform? I asked the users which operator would you like to use based on this input i used if statement
What opportunities exist to create small methods for this project? I need to use different methods to make my code shorter by stop asking the same questions.
In the next project, what would you change about your process? What would you keep doing? In next code I will use more methods and try to organize my code more and add comments to make it more easy to read. I will keep checking the users inputs to make sure that the users enter the correct inputs

Copy link
Copy Markdown

@beccaelenzil beccaelenzil left a comment

Choose a reason for hiding this comment

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

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.

Comment thread calculator.rb
print "How many operations would you like to do?: "
operator_num = gets.chomp

while operator_num !~ /^-?[0-9]+$/
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Make sure you cite your source if you found the regular expression somewhere.

Comment thread calculator.rb
end
operator_num = operator_num.to_i

operator_num.times do |i|
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a very nice feature. I enjoyed being able to complete multiple problems without rerunning the program!

Comment thread calculator.rb
operator = gets.chomp
end
operator = operator
if operator_array.include?(operator)
Copy link
Copy Markdown

@beccaelenzil beccaelenzil Aug 9, 2019

Choose a reason for hiding this comment

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

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?

Comment thread calculator.rb
print "\nEnter your second number: "
num_2 = gets.chomp
end
num_2 = num_2.to_i
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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).

Comment thread calculator.rb
end
num_2 = num_2.to_i

if operator == "add" || operator == "+"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider using a case/when block to simplify your code.

@beccaelenzil
Copy link
Copy Markdown

Calculator

What We're Looking For

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

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