Advertisement
Aranyalma2

Számológép_processing

Aug 17th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 14.15 KB | None | 0 0
  1. float x1;
  2. float x2;
  3. float answer;
  4. boolean click;
  5. boolean add;
  6. boolean sub;
  7. boolean div;
  8. boolean mult;
  9. boolean operator;
  10. boolean thirdclick;
  11. boolean firstclick;
  12. void setup()
  13. {
  14.   background(255);
  15.   textAlign(CENTER);
  16.   size(600, 600);
  17.   strokeWeight(3);
  18.   //horizontal lines
  19.   line(0, .2*height, width, .2*height);
  20.   line(0, .4*height, width, .4*height);
  21.   line(0, .6*height, width, .6*height);
  22.   line(0, .8*height, .8*width, .8*height);
  23.   //verticle lines
  24.   line(.2*width, 0, .2*width, height);
  25.   line(.4*width, .2*height, .4*width, height);
  26.   line(.6*width, .2*height, .6*width, height);
  27.   line(.8*width, 0, .8*width, height);
  28.   //numbers and operator symbols
  29.   fill(0);
  30.   textSize(35);
  31.   text('1', .1*width, .3*height);
  32.   text('2', .3*width, .3*height);
  33.   text('3', .5*width, .3*height);
  34.   text('4', .1*width, .5*height);
  35.   text('5', .3*width, .5*height);
  36.   text('6', .5*width, .5*height);
  37.   text('7', .1*width, .7*height);
  38.   text('8', .3*width, .7*height);
  39.   text('9', .5*width, .7*height);
  40.   text('0', .1*width, .9*height);
  41.   text('.', .3*width, .9*height);
  42.   text("(-)", .5*width, .9*height);
  43.   text("Clr", .1*width, .1*height);
  44.   text("Mem", .9*width, .1*height);
  45.   text("*", .7*width, .3*height);
  46.   text("/", .7*width, .5*height);
  47.   text("-", .7*width, .7*height);
  48.   text("+", .7*width, .9*height);
  49.   text("=", .9*width, .8*height);
  50.   text("Pi", .9*width, .5*height);
  51.   text("?", .9*width, .3*height);
  52.   //default settings
  53.   click = true;
  54.   add = false;
  55.   sub = false;
  56.   div = false;
  57.   mult = false;
  58.   operator = false;
  59.   thirdclick = false;
  60.   firstclick = false;
  61.   x2 = 1;
  62. }
  63.  
  64. void draw()
  65. {
  66.   if (mult==true)
  67.   {
  68.     answer = x1 * x2;
  69.   }
  70.   if (div==true)
  71.   {
  72.     answer = x1 / x2;
  73.   }
  74.   if (sub==true)
  75.   {
  76.     answer = x1 - x2;
  77.   }
  78.   if (add == true)
  79.   {
  80.     answer = x1 + x2;
  81.   }
  82.   if (firstclick==true)
  83.   {
  84.     if (mousePressed)
  85.     {
  86.       textSize(8);
  87.       text(x1, .25*width, .1*height);
  88.     }
  89.   }
  90.   if (thirdclick==true)
  91.   {
  92.     if (mousePressed)
  93.     {
  94.       textSize(8);
  95.       text(x2, .35*width, .1*height);
  96.     }
  97.   }
  98. }
  99. void mousePressed()
  100. {
  101.   {
  102.     if (mouseY >= .6*height)
  103.     {
  104.       if (mouseY <= height)
  105.       {
  106.         if (mouseX >= .8*width)
  107.         {
  108.           if (mouseX <= width)
  109.           {
  110.             if (mousePressed)
  111.             {
  112.               firstclick=false;
  113.               textSize(35);
  114.               fill(255);
  115.               rect(.2*width, 0, .6*width, .2*height);
  116.               fill(0);
  117.               text(answer, .6*width, .1*height);
  118.               click = true;
  119.               add = false;
  120.               sub = false;
  121.               div = false;
  122.               mult = false;
  123.               thirdclick = false;
  124.             }
  125.           }
  126.         }
  127.       }
  128.     }
  129.     if (click==true)
  130.     {
  131.       if (mouseX <=.2*width)
  132.       {
  133.         if (mouseX >=0)
  134.         {
  135.           if (mouseY <=.8*height)
  136.           {
  137.             if (mouseY >=.6*height)
  138.             {
  139.               if (mousePressed)
  140.               {
  141.                 x1 = 7;
  142.               }
  143.             }
  144.           }
  145.         }
  146.       }
  147.     }
  148.     if (click==true)
  149.     {
  150.       if (mouseX <=.6*width)
  151.       {
  152.         if (mouseX >=.4* width)
  153.         {
  154.           if (mouseY <=.8*height)
  155.           {
  156.             if (mouseY >=.6*height)
  157.             {
  158.               if (mousePressed)
  159.               {
  160.                 x1 = 9;
  161.                 operator = true;
  162.                 firstclick = true;
  163.               }
  164.             }
  165.           }
  166.         }
  167.       }
  168.     }
  169.     if (click==true)
  170.     {
  171.       if (mouseX <=.4*width)
  172.       {
  173.         if (mouseX >=.2*width)
  174.         {
  175.           if (mouseY <=.8*height)
  176.           {
  177.             if (mouseY >=.6*height)
  178.             {
  179.               if (mousePressed)
  180.               {
  181.                 x1 = 8;
  182.                 operator = true;
  183.                 firstclick = true;
  184.               }
  185.             }
  186.           }
  187.         }
  188.       }
  189.     }
  190.     if (click==true)
  191.     {
  192.       if (mouseX <=.6*width)
  193.       {
  194.         if (mouseX >=.4*width)
  195.         {
  196.           if (mouseY <=.6*height)
  197.           {
  198.             if (mouseY >=.4*height)
  199.             {
  200.               if (mousePressed)
  201.               {
  202.                 x1 = 6;
  203.                 operator = true;
  204.                 firstclick = true;
  205.               }
  206.             }
  207.           }
  208.         }
  209.       }
  210.     }
  211.     if (click==true)
  212.     {
  213.       if (mouseX <=.4*width)
  214.       {
  215.         if (mouseX >=.2*width)
  216.         {
  217.           if (mouseY <=.6*height)
  218.           {
  219.             if (mouseY >=.4*height)
  220.             {
  221.               if (mousePressed)
  222.               {
  223.                 x1 = 5;
  224.                 operator = true;
  225.                 firstclick = true;
  226.               }
  227.             }
  228.           }
  229.         }
  230.       }
  231.     }
  232.     if (click==true)
  233.     {
  234.       if (mouseX <=.2*width)
  235.       {
  236.         if (mouseX >=0)
  237.         {
  238.           if (mouseY <=.6*height)
  239.           {
  240.             if (mouseY >=.4*height)
  241.             {
  242.               if (mousePressed)
  243.               {
  244.                 x1 = 4;
  245.                 operator = true;
  246.                 firstclick = true;
  247.               }
  248.             }
  249.           }
  250.         }
  251.       }
  252.     }
  253.     if (click==true)
  254.     {
  255.       if (mouseX <=.6*width)
  256.       {
  257.         if (mouseX >=.4*width)
  258.         {
  259.           if (mouseY <=.4*height)
  260.           {
  261.             if (mouseY >=.2*height)
  262.             {
  263.               if (mousePressed)
  264.               {
  265.                 x1 = 3;
  266.                 operator = true;
  267.                 firstclick = true;
  268.               }
  269.             }
  270.           }
  271.         }
  272.       }
  273.     }
  274.     if (click==true)
  275.     {
  276.       if (mouseX <=.4*width)
  277.       {
  278.         if (mouseX >=.2*width)
  279.         {
  280.           if (mouseY <=.4*height)
  281.           {
  282.             if (mouseY >=.2*height)
  283.             {
  284.               if (mousePressed)
  285.               {
  286.                 x1 = 2;
  287.                 operator = true;
  288.                 firstclick = true;
  289.               }
  290.             }
  291.           }
  292.         }
  293.       }
  294.     }
  295.     if ( click == true)
  296.     {
  297.       if (mouseX <=.2*width)
  298.       {
  299.         if (mouseX >=0)
  300.         {
  301.           if (mouseY <=.4*height)
  302.           {
  303.             if (mouseY >=.2*height)
  304.             {
  305.               if (mousePressed)
  306.               {
  307.                 x1 = 1;
  308.                 operator = true;
  309.                 firstclick = true;
  310.               }
  311.             }
  312.           }
  313.         }
  314.       }
  315.     }
  316.   }
  317.   if (click==false)
  318.   {
  319.     if (mouseX <=.6*width)
  320.     {
  321.       if (mouseX >=.4*height)
  322.       {
  323.         if (mouseY <=.8*height)
  324.         {
  325.           if (mouseY >=.6*height)
  326.           {
  327.             if (mousePressed)
  328.             {
  329.               x2 = 9;
  330.               thirdclick = true;
  331.             }
  332.           }
  333.         }
  334.       }
  335.     }
  336.   }
  337.   if (click==false)
  338.   {
  339.     if (mouseX <=.4*width)
  340.     {
  341.       if (mouseX >=.2*height)
  342.       {
  343.         if (mouseY <=.8*height)
  344.         {
  345.           if (mouseY >=.6*height)
  346.           {
  347.             if (mousePressed)
  348.             {
  349.               x2 = 8;
  350.               thirdclick = true;
  351.             }
  352.           }
  353.         }
  354.       }
  355.     }
  356.   }
  357.   if (click==false)
  358.   {
  359.     if (mouseX <=.2*width)
  360.     {
  361.       if (mouseX >=0)
  362.       {
  363.         if (mouseY <=.8*height)
  364.         {
  365.           if (mouseY >=.6*height)
  366.           {
  367.             if (mousePressed)
  368.             {
  369.               x2 = 7;
  370.               thirdclick = true;
  371.             }
  372.           }
  373.         }
  374.       }
  375.     }
  376.   }
  377.   if (click==false)
  378.   {
  379.     if (mouseX <=.6*width)
  380.     {
  381.       if (mouseX >=.4*width)
  382.       {
  383.         if (mouseY <=.6*height)
  384.         {
  385.           if (mouseY >=.4*height)
  386.           {
  387.             if (mousePressed)
  388.             {
  389.               x2 = 6;
  390.               thirdclick = true;
  391.             }
  392.           }
  393.         }
  394.       }
  395.     }
  396.   }
  397.   if (click==false)
  398.   {
  399.     if (mouseX <=.4*width)
  400.     {
  401.       if (mouseX >=.2*width)
  402.       {
  403.         if (mouseY <=.6*height)
  404.         {
  405.           if (mouseY >=.4*height)
  406.           {
  407.             if (mousePressed)
  408.             {
  409.               x2 = 5;
  410.               thirdclick = true;
  411.             }
  412.           }
  413.         }
  414.       }
  415.     }
  416.   }
  417.   if (click==false)
  418.   {
  419.     if (mouseX <=.2*width)
  420.     {
  421.       if (mouseX >=0)
  422.       {
  423.         if (mouseY <=.6*height)
  424.         {
  425.           if (mouseY >=.4*height)
  426.           {
  427.             if (mousePressed)
  428.             {
  429.               x2 = 4;
  430.               thirdclick = true;
  431.             }
  432.           }
  433.         }
  434.       }
  435.     }
  436.   }
  437.   if (click==false)
  438.   {
  439.     if (mouseX <=.6*width)
  440.     {
  441.       if (mouseX >=.4*width)
  442.       {
  443.         if (mouseY <=.4*height)
  444.         {
  445.           if (mouseY >=.2*height)
  446.           {
  447.             if (mousePressed)
  448.             {
  449.               x2 = 3;
  450.               thirdclick = true;
  451.             }
  452.           }
  453.         }
  454.       }
  455.     }
  456.   }
  457.   if (click==false)
  458.   {
  459.     if (mouseX <=.4*width)
  460.     {
  461.       if (mouseX >=.2*width)
  462.       {
  463.         if (mouseY <=.4*height)
  464.         {
  465.           if (mouseY >=.2*height)
  466.           {
  467.             if (mousePressed)
  468.             {
  469.               x2 = 2;
  470.               thirdclick = true;
  471.             }
  472.           }
  473.         }
  474.       }
  475.     }
  476.   }
  477.   if (click == false)
  478.   {
  479.     if (mouseX <=.2*width)
  480.     {
  481.       if (mouseX >=0)
  482.       {
  483.         if (mouseY <=.4*height)
  484.         {
  485.           if (mouseY >=.2*height)
  486.           {
  487.             if (mousePressed)
  488.             {
  489.               x2 = 1;
  490.               thirdclick = true;
  491.             }
  492.           }
  493.         }
  494.       }
  495.     }
  496.   }
  497.   if (operator == true)
  498.   {
  499.     if (mouseY >= .6*height)
  500.     {
  501.       if (mouseY <= .8*height)
  502.       {
  503.         if (mouseX >= .6*width)
  504.         {
  505.           if (mouseX <= .8*width)
  506.           {
  507.             if (mousePressed)
  508.             {
  509.               sub = true;
  510.               click = false;
  511.               text("-", .3*width, .1*height);
  512.               operator = false;
  513.               add = false;
  514.               mult = false;
  515.               div = false;
  516.             }
  517.           }
  518.         }
  519.       }
  520.     }
  521.   }
  522.   if ( operator == true)
  523.   {
  524.     if (mouseY >= .4*height)
  525.     {
  526.       if (mouseY <= .6*height)
  527.       {
  528.         if (mouseX >= .6*width)
  529.         {
  530.           if (mouseX <= .8*width)
  531.           {
  532.             if (mousePressed)
  533.             {
  534.               div = true;
  535.               click = false;
  536.               text("/", .3*width, .1*height);
  537.               operator = false;
  538.               add = false;
  539.               sub = false;
  540.               mult = false;
  541.             }
  542.           }
  543.         }
  544.       }
  545.     }
  546.   }
  547.   if (operator == true)
  548.   {
  549.     if (mouseY >= .2*height)
  550.     {
  551.       if (mouseY <= .4*height)
  552.       {
  553.         if (mouseX >= .6*width)
  554.         {
  555.           if (mouseX <= .8*width)
  556.           {
  557.             if (mousePressed)
  558.             {
  559.               mult = true;
  560.               click = false;
  561.               text("*", .3*width, .1*height);
  562.               operator = false;
  563.               add = false;
  564.               sub = false;
  565.               div = false;
  566.             }
  567.           }
  568.         }
  569.       }
  570.     }
  571.   }
  572.   if (operator == true)
  573.   {
  574.     if (mouseY >= .8*height)
  575.     {
  576.       if (mouseY <= height)
  577.       {
  578.         if (mouseX >= .6*width)
  579.         {
  580.           if (mouseX <= .8*width)
  581.           {
  582.             if (mousePressed)
  583.             {
  584.               add = true;
  585.               click = false;
  586.               text("+", .3*width, .1*height);
  587.               operator = false;
  588.               sub = false;
  589.               div = false;
  590.               mult = false;
  591.             }
  592.           }
  593.         }
  594.       }
  595.     }
  596.   }
  597.   if (mouseX <= .2*width)
  598.   {
  599.     if (mouseX >= 0)
  600.     {
  601.       if (mouseY<= .2*height)
  602.       {
  603.         if (mouseY>= 0)
  604.         {
  605.           if (mousePressed)
  606.           {
  607.             click = true;
  608.             add = false;
  609.             sub = false;
  610.             div = false;
  611.             mult = false;
  612.             operator = false;
  613.             thirdclick = false;
  614.             x2 = 1;
  615.             x1 = 0;
  616.             fill(255);
  617.             rect(.2*width, 0, .6*width, .2*height);
  618.           }
  619.         }
  620.       }
  621.     }
  622.   }
  623.   if (click==true)
  624.   {
  625.     if (mouseX>=.8*width)
  626.     {
  627.       if (mouseX<=width)
  628.       {
  629.         if (mouseY>=0)
  630.         {
  631.           if (mouseY<=.2*height)
  632.           {
  633.             if (mousePressed)
  634.             {
  635.               x1 = answer;
  636.               operator = true;
  637.               firstclick = true;
  638.             }
  639.           }
  640.         }
  641.       }
  642.     }
  643.   }
  644.   if (click==true)
  645.   {
  646.     if (mouseX<=.2*width)
  647.     {
  648.       if (mouseX>=0)
  649.       {
  650.         if (mouseY<=height)
  651.         {
  652.           if (mouseY>=.8*height)
  653.           {
  654.             x1=0;
  655.             operator = true;
  656.           }
  657.         }
  658.       }
  659.     }
  660.   }
  661.   if (click==false)
  662.   {
  663.     if (mouseX<=.2*width)
  664.     {
  665.       if (mouseX>=0)
  666.       {
  667.         if (mouseY<=height)
  668.         {
  669.           if (mouseY>=.8*height)
  670.           {
  671.             x2=0;
  672.           }
  673.         }
  674.       }
  675.     }
  676.   }
  677.   if (mouseX>=.4*width)
  678.   {
  679.     if (mouseX<=.6*width)
  680.     {
  681.       if (mouseY>=.8*width)
  682.       {
  683.         if (mouseY<= height)
  684.         {
  685.           if (mousePressed)
  686.           {
  687.             answer = answer * -1;
  688.             textSize(35);
  689.             fill(255);
  690.             rect(.2*width, 0, .6*width, .2*height);
  691.             fill(0);
  692.             text(answer, .6*width, .1*height);
  693.           }
  694.         }
  695.       }
  696.     }
  697.   }
  698.   if (click==true)
  699.   {
  700.     if (mouseX <=width)
  701.     {
  702.       if (mouseX >=.8*width)
  703.       {
  704.         if (mouseY <=.6*height)
  705.         {
  706.           if (mouseY >=.4*height)
  707.           {
  708.             if (mousePressed)
  709.             {
  710.               x1 = PI;
  711.               operator = true;
  712.               firstclick = true;
  713.             }
  714.           }
  715.         }
  716.       }
  717.     }
  718.   }
  719.   if (click==false)
  720.   {
  721.     if (mouseX <=width)
  722.     {
  723.       if (mouseX >=.8*width)
  724.       {
  725.         if (mouseY <=.6*height)
  726.         {
  727.           if (mouseY >=.4*height)
  728.           {
  729.             if (mousePressed)
  730.             {
  731.               x2 = PI;
  732.               thirdclick = true;
  733.             }
  734.           }
  735.         }
  736.       }
  737.     }
  738.   }
  739. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement