project link: http://codepen.io/YUGANO/pen/amWRQo
Hi everyone. I looked at lots of calculator code and realize that there is a relation between numbers, operator and dot but most of the codes include calculating every situation independently every time. so i want to create a little bit different logic like that.
- at first you have to type number so i created a boolean “sayi” assign false to it and put it in operator, dot and equal buttons logic mechanism. you cant type any of them until type number is pushed.
- then created boolean “noktakilit” for dot button. it is true at the beginning but if you push dot button once, it make noktakilit false and it is only became true if you type operator button. you must follow that order dot number operator number. they lock and open each other in turn.
- operators are simple they just have a sayi boolean. you can type after type at least one number.
- equal requires two boolean sayi and sonuckilit. sonuckilit is changed when you type operator button at least once and you can type equal button after that.
- the hardest part is to make clear buttons logic. it check last element and in some case last two element to transform booleans former situation.
- and there is possibility of error because there are too much combination and i am not sure i did handle it all. so i want your help to find issue.
I am waiting for your repsonce and feedback because i made first time a project :). I skipped all project until now and this is my favorite project because this involves math, making logic, only built in objects.