Advertisement
Guest User

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Calculator { public partia

a guest
Feb 16th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace Calculator
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20. private void label1_Click(object sender, EventArgs e)
  21. {
  22.  
  23. }
  24.  
  25. private void Form1_Load(object sender, EventArgs e)
  26. {
  27.  
  28. }
  29.  
  30. private void Multiplication_Click(object sender, EventArgs e)
  31. {
  32. //очищение памяти + не нажата ли кнопка??
  33. }
  34.  
  35. private void Division_Click(object sender, EventArgs e)
  36. {
  37.  
  38. }
  39. }
  40.  
  41. public interface IInterfaceCalc
  42. {
  43. void Put_A(double a); //запомнить a
  44. void Clear_A(); //очистить память
  45. double Multiplication(double b); //умножение
  46. double Division(double b); //деление
  47. double Sum(double b); //сумма
  48. double Subtraction(double b); //вычитание
  49. double Square(); //квадрат
  50. double Factorial(); //факториал
  51. double MemoryShow(); //показать содержимое регистра памяти
  52. void Memory_Clear(); //стереть содержимое регистра
  53. }
  54.  
  55. public class Calc : IInterfaceCalc
  56. {
  57. private double a = 0;
  58. private double memory = 0;
  59.  
  60. public void Put_A(double a)
  61. {
  62. this.a = a;
  63. }
  64.  
  65. public void Clear_A()
  66. {
  67. a = 0;
  68. }
  69.  
  70. public double Multiplication(double b)
  71. {
  72. return a * b;
  73. }
  74.  
  75. public double Division(double b)
  76. {
  77. return a / b;
  78. }
  79.  
  80. public double Sum(double b)
  81. {
  82. return a + b;
  83. }
  84.  
  85. public double Subtraction(double b)
  86. {
  87. return a - b;
  88. }
  89.  
  90. public double Square()
  91. {
  92. return Math.Pow(a, 2.0);
  93. }
  94.  
  95. public double Factorial()
  96. {
  97. double f = 1;
  98. for (int i = 1; i <= a; i++)
  99. {
  100. f *= (double)i;
  101. }
  102. return f;
  103. }
  104.  
  105. public double MemoryShow()
  106. {
  107. return memory;
  108. }
  109.  
  110. public void Memory_Clear()
  111. {
  112. memory = 0.0;
  113. }
  114. }
  115.  
  116.  
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement