Skip to content

Conversation

@olgapatrakova
Copy link

Assignment Submission: Calculator

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions:

Reflection

Question Answer
What went well in your code style, such as indentation, spacing, variable names, readability, etc.? What was lacking? Indentation, spacing, variable names went well. I could use more methods and could spend less time on debugging.
How did your code keep track of user input? It saves user input in variables for both numbers
How did your code determine what operation to perform? It uses case-when matching for operators input
What opportunities exist to create small methods for this project? e.g. I used methods for user input validation and for converting strings to integers or to floats depending on the presence of decimal point.
In the next project, what would you change about your process? What would you keep doing? I would try to use other ways of user input validation, try new techniques. I will keep using regular expressions and ternary operators to practice them, will use more methods and will be trying to find better and different ways to express the same idea of my code.

@beccaelenzil
Copy link

Calculator

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
Correctly uses conditionals (if/else/elsif) ✔️
Correctly uses loops (while/until) ✔️
Correctly uses gets.chomp ✔️
Correctly uses variables ✔️
Correctly creates and uses custom methods ✔️

Functional Requirements

Functional Requirement yes/no
User can input two numbers and an operator and perform addition ✔️
User can input in two numbers and an operator and can perform subtraction ✔️
User gets feedback from the CLI when attempting to divide by zero, and the program does not give an error ✔️

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 3+ in Code Review && 2+ in Functional Requirements ✔️
Yellow (Approaches Standards) 2 in Code Review && 2+ in Functional Requirements
Red (Not at Standard) 0,1 in Code Review or 0,1 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging

Additional Feedback

Great work on this assignment! You did a great job breaking up the logic into small subproblems using custom methods. You gracefully handle invalid user input. Keep up the hard work.

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Elegant/Clever
Descriptive/Readable
Logical/Organized

return number
end

puts "Please enter the first number "

Choose a reason for hiding this comment

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

Consider using a method or loop to get user input to DRY up your code.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the code review and great comments. I'll do my best to dry up my code next time.


# Check if user input is not a letter
def input_check(number)
until number.match(/\A[-]?\d+(\.\d+)?\z/)

Choose a reason for hiding this comment

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

nice use of regex :)

Copy link
Author

Choose a reason for hiding this comment

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

Thank you, Becca!

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