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

Ampers: Zheng Cao #34

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

Ampers: Zheng Cao #34

wants to merge 7 commits into from

Conversation

2020dream
Copy link

Calculator

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
Describe how you stored user input in your program? Currently, all inputs from user are stored in a simple variable (user_operation, user_number_type, first_number, second_number). In a more advanced version of the program, which accepts more than two numbers and more than one operation, the whole formula will be stored in a string, then converted to relevant information for computation.
How did you determine what operation to perform? Users are provided a list of all operations supported by the program. Users' choice is collected and used to determine which operation to perform. Case match is used for implementation of computation.
Do you feel like you used consistent indentation throughout your code? Yes.
If you had more time, what would you have added to or changed about the program? 1. Finish the advanced version of the program, which accepts more than two numbers and more than one operation, including parenthesis if possible. 2. Fix a corner case in the float_check method (a float with last digit as 0, such as 2.10). Right now, if the user enter 2.10, the program treats it as an invalid float number. This is because "2.10".to_f.to_s generates "2.1", and "2.10" != "2.1". This won't affect the functions of the calculator. But because this type of number is meaningful in certain context, such as money value, it's meaningful to allow users to enter such numbers.

@tildeee
Copy link

tildeee commented Feb 12, 2018

Calculator

What We're Looking For

Feature Feedback
Takes in two numbers and an operator and performs the mathematical operation. x
Readable code with consistent indentation. x

Overall, great job!

Your user_choice_check method is really robust; I like that you pass in a list of valid choices as an argument. It makes the code very flexible

I think how you handle checking the input if it's a valid integer or float (with the lines integer.to_s == integer_string and float.to_s == float_string) are very clever :)

One last clever thing you did was just puts operations and puts number_types. This way, if you update the arrays operations or number_types, you don't have to update the operations or number types array.

@2020dream
Copy link
Author

@tildeee Thanks for the comments :) My first thought for input check was to use regex, then I realized it would take me quite a while to figure out how to write regex code correctly. I don't see regex in our syllabus. Are we going to learn about it in the future? If not, do you have any recommendations for me to look at?

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