Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 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 cash
  12. {
  13. public partial class Form1 : Form
  14. {
  15.  
  16. guy joe;
  17. guy bob;
  18. int bank = 100;
  19.  
  20. public void UpdateForm()
  21. {
  22. label1.Text = joe.Name + " has $" + joe.Cash;
  23. label2.Text = bob.Name + " has $" + bob.Cash;
  24. label3.Text = "The bank has $" + bank;
  25. }
  26. public Form1()
  27. {
  28. InitializeComponent();
  29.  
  30. bob = new guy()
  31. {
  32. Cash = 50,
  33. Name = "Bob"
  34. };
  35.  
  36.  
  37. joe = new guy()
  38. {
  39. Cash = 50,
  40. Name = "Joe"
  41. };
  42.  
  43. UpdateForm();
  44. }
  45.  
  46. private void button1_Click(object sender, EventArgs e)
  47. {
  48. if (bank >= 10) {
  49. bank -= joe.Receivecash(10);
  50. UpdateForm();
  51. } else {
  52. MessageBox.Show("The bank is out of money");
  53. }
  54. }
  55.  
  56. private void button2_Click(object sender, EventArgs e)
  57. {
  58. bank += bob.GiveCash(5);
  59. UpdateForm();
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement