Sunday, July 26, 2015

Calculator IV: Arithmetic Bitches!!

Github

So my logic was okay; I did work through the process correctly with my spreadsheet, but I left a few things out of my code. The first and biggest issue, was that my equal method did not include the display method, which is why nothing appeared onscreen. Once that was sorted, I noticed another problem: When a user presses the equal button, after a calculation I want them to be able to press it again and perform the operation again. 5 + 3 = 8. Press equal again and get 11. In this scenario, I was getting 8.

This was something that I worked out, but just forgot to include in my code. All I needed to fix it was to add a simple conditional in my equal method:

if(number2 == null){     
 number2 = Double.parseDouble(screenString);
}

Before the equal method calculates, it checks for a value in number2, if there is one, it stays then same, if not, then it's value becomes whatever's on screen.


Next Steps 


Now I think all I have left to do is some general prettying up. I want the button's and screen to take up the whole screen and maybe even to add some style to them. I'd like to also include another field that displays numbers and operators when they're not on screen.

No comments:

Post a Comment