Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 cash
- {
- public partial class Form1 : Form
- {
- guy joe;
- guy bob;
- int bank = 100;
- public void UpdateForm()
- {
- label1.Text = joe.Name + " has $" + joe.Cash;
- label2.Text = bob.Name + " has $" + bob.Cash;
- label3.Text = "The bank has $" + bank;
- }
- public Form1()
- {
- InitializeComponent();
- bob = new guy()
- {
- Cash = 50,
- Name = "Bob"
- };
- joe = new guy()
- {
- Cash = 50,
- Name = "Joe"
- };
- UpdateForm();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (bank >= 10) {
- bank -= joe.Receivecash(10);
- UpdateForm();
- } else {
- MessageBox.Show("The bank is out of money");
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- bank += bob.GiveCash(5);
- UpdateForm();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement