dessel191

Ekran

May 8th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.23 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace WindowsFormsApp1
  8. {
  9.     public static class Ekran
  10.     {
  11.         private static string s;
  12.         private static bool dot = false;
  13.         private static bool o = false;
  14.         private static int d = 0;
  15.  
  16.         public static int ostdzialanied()
  17.         {
  18.             return d;
  19.         }
  20.  
  21.  
  22.         public static string ostdzialanie()
  23.         {
  24.             switch (d)
  25.             {
  26.                 case 0:
  27.                     return "";
  28.                
  29.                 case 1:
  30.                     return "+";
  31.  
  32.                 case 2:
  33.                     return "-";
  34.  
  35.                 case 3:
  36.                     return "*";
  37.  
  38.                 case 4:
  39.                     return "/";
  40.                 case 5:
  41.                     return "x^2";
  42.                 case 6:
  43.                     return "1/x";
  44.                 case 7:
  45.                     return "%";
  46.                 case 8:
  47.                     return "+/-";
  48.                 case 9:
  49.                     return "SQRT";
  50.  
  51.  
  52.                 default:
  53.                     return "";
  54.  
  55.             }
  56.         }
  57.        
  58.         public static void setdzialanie(int i)
  59.         {
  60.             d = i;
  61.         }
  62.        
  63.         public static void set(double a)
  64.         {          
  65.              set(a.ToString());
  66.         }
  67.  
  68.         public static void set(string a)
  69.         {
  70.             s = a;
  71.         }
  72.  
  73.         public static void add(double a)
  74.         {
  75.             add(a.ToString());
  76.         }
  77.  
  78.         public static void add(string a)
  79.         {
  80.             if (a.Equals("."))
  81.             {
  82.                 if (!dot && !o)
  83.                 {
  84.                     s += "0.";
  85.                     dot = true;
  86.                     o = true;
  87.                 }
  88.                 else if (!dot && o)
  89.                 {
  90.                     s += ".";
  91.                     dot = true;
  92.                 }
  93.  
  94.             }
  95.             else if (a.Equals("0"))
  96.             {
  97.                 if (dot)
  98.                 {
  99.                     s += "0";
  100.                 }
  101.                 else
  102.                 {
  103.                     if (!o)
  104.                     {
  105.                         s += "0";
  106.                         o = true;
  107.                     }
  108.                 }
  109.             }
  110.             else if (a.Equals("00"))
  111.             {
  112.                 if(dot)
  113.                 {
  114.                     s += "00";
  115.                 }
  116.                 else if (!o)
  117.                 {
  118.                     o = true;
  119.                     s += "0";
  120.                 }
  121.             }
  122.             else
  123.             {
  124.                 if (!dot && !o)
  125.                     s += a;
  126.                 else if (dot)
  127.                     s += a;
  128.                 else if (o && !dot)
  129.                     return;
  130.             }
  131.  
  132.                
  133.         }
  134.  
  135.         public static void clr()
  136.         {
  137.             s = null;
  138.             dot = false;
  139.             o = false;
  140.         }
  141.  
  142.         public static string rets()
  143.         {
  144.             return s;
  145.         }
  146.         public static double retd()
  147.         {
  148.             return Double.Parse(s);
  149.         }
  150.     }
  151. }
Advertisement
Add Comment
Please, Sign In to add comment