Tuesday, July 14, 2015

Calculator II



Github

Just a quick update. I added functionality to my number and clear buttons. I originally intended to set up onclick listeners for each button, but I took a look at an app I made for a Udacity course and decided to make methods--press1, press2, etc.--and reference them in the each button's android:onClick property in XML. It's not much easier to do it that way, it just seems cleaner to me.

Taking the screenshots, I realized I need to prevent users from pressing the decimal button if it's already been pressed, and limit the number of characters that can be entered.

Right now I've got the numbers stored in a string that is added to each time the button is pressed. I think what I'm going to do next is, whenever an operator button is pressed, I'll convert whatever is in the string to a double, store that variable in a double and clear the screen. Then I can perform whatever operation is pressed with that double and whatever the new string is.

No comments:

Post a Comment