Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 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 WindowsFormsApplication3
  12. {
  13. public partial class Form1 : Form
  14. {
  15. class cmath
  16. {
  17. public int tambah (int a, int b)
  18. { return a + b;
  19. }
  20. public int kurang ( int a , int b )
  21. {
  22. return a - b;
  23.  
  24. }
  25. }
  26. class cmath2 : cmath
  27. {
  28. public int kali ( int a, int b )
  29. {
  30. return a * b;
  31. }
  32. public int bagi ( int a , int b )
  33. {
  34. return a / b;
  35. }
  36. }
  37. public Form1()
  38. {
  39. InitializeComponent();
  40. }
  41.  
  42. private void Form1_Load(object sender, EventArgs e)
  43. {
  44.  
  45. }
  46.  
  47. private void button1_Click(object sender, EventArgs e)
  48. {
  49. cmath vcmath = new cmath();
  50. int vhasil;
  51. vhasil = vcmath.tambah(1, 2);
  52. MessageBox.Show(vhasil.ToString());
  53.  
  54. }
  55.  
  56. private void button2_Click(object sender, EventArgs e)
  57. {
  58. cmath2 vcmath2 = new cmath2();
  59. int vhasil;
  60. vhasil = vcmath2.tambah(1, 2);
  61. MessageBox.Show(vhasil.ToString());
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement