{"id":696,"date":"2009-10-29T12:36:36","date_gmt":"2009-10-29T18:36:36","guid":{"rendered":"http:\/\/alliwalk.com\/blog\/?p=696"},"modified":"2010-10-17T00:54:01","modified_gmt":"2010-10-17T06:54:01","slug":"icm-week-8-midterm-my-fortune-telling-magic-8-ball-calculator","status":"publish","type":"post","link":"https:\/\/alliwalk.com\/blog\/2009\/10\/icm-week-8-midterm-my-fortune-telling-magic-8-ball-calculator\/","title":{"rendered":"ICM Week 8: Midterm! My fortune telling, Magic 8 Ball calculator"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"alignleft size-full wp-image-704\" title=\"Fortune Calculator\" src=\"http:\/\/alliwalk.com\/blog\/wp-content\/uploads\/2009\/10\/calc.png\" alt=\"Fortune Calculator\" width=\"150\" height=\"214\" \/><br \/>\n<br clear =\"right\"\/><br \/>\nLast week we discussed ideas for our midterm and I presented something I&#8217;d been thinking about since Week 4. My idea was to create a calculator that doesn&#8217;t work&#8230;or works more like a Magic 8 Ball than a calculator. It actually does add and subtract but what you get are strings, not numbers.<\/p>\n<p>When I started working on it, I was going crazy trying to figure out how to create a class for every property that a button would have &#8211; rollover detection, button press detection, the value of each button, and how to store the value of each button so that you could actually do a calculation. Then, it was suggested that I use a library to create the buttons. (Duh.) I chose ControlP5. Admittedly, using the library was a revelation and it helped me progress my work forward by at least a week. I think I would have lost it if I had to create an entire button class in a week, and figure out how to make the rest of the calculator work.<\/p>\n<p>So after all that, I again got help adding the buttons and creating the first of 2 switch statements to determine button press. The second, I made on my own. But, eventually I was able to do a lot of work alone, creating the array of strings, calling the functions to print the strings, creating outlines for the buttons, and adding the ability to subtract. I also added buttons to the calculator that have nothing to do with math at all. Like a &#8216;Q&#8217; button, an &#8216;&amp;&#8217; button, and a &#8216;?&#8217; button. I may create put in other mathematical operators, &#8216;*&#8217; and &#8216;\/&#8217; so that it seems more like a true calculator&#8230;we&#8217;ll see.<\/p>\n<p>I am disappointed that the ControlP5 library doesn&#8217;t have much in the way of customization of the buttons. The text is really tiny and I&#8217;d prefer to make it look more calculator-like. Eventually, maybe I will end up creating a button class and then be able to modify the look a little bit better. For now, I&#8217;m happy that I have a calculator that (mostly) works.<\/p>\n<p>If you use it, remember that it can only add or subtract two numbers. If you do a compound calculation, like &#8216;N + Y &#8211; R &amp; S&#8217;, you&#8217;ll get results from the last operator used, in this example &#8216;&amp;&#8217;. It also works best if you &#8216;Clear&#8217; your results after each calculation.<\/p>\n<p><a href=\"http:\/\/alliwalk.com\/ICM2009\/Midterm\/\">Fortune telling, Magic 8 Ball Calculator<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week we discussed ideas for our midterm and I presented something I&#8217;d been thinking about since Week 4. My idea was to create a calculator that doesn&#8217;t work&#8230;or works more like a Magic 8 Ball than a calculator. It actually does add and subtract but what you get are strings, not numbers. When I &hellip; <a href=\"https:\/\/alliwalk.com\/blog\/2009\/10\/icm-week-8-midterm-my-fortune-telling-magic-8-ball-calculator\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;ICM Week 8: Midterm! My fortune telling, Magic 8 Ball calculator&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,1,84,76],"tags":[138,139],"_links":{"self":[{"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/posts\/696"}],"collection":[{"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/comments?post=696"}],"version-history":[{"count":12,"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/posts\/696\/revisions"}],"predecessor-version":[{"id":705,"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/posts\/696\/revisions\/705"}],"wp:attachment":[{"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/media?parent=696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/categories?post=696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alliwalk.com\/blog\/wp-json\/wp\/v2\/tags?post=696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}