Head First C# Code: Chapter 9 Joe and Bob Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace __Joe_and_Bob__serialized
{
public partial class Form1 : Form
{
Guy joe;
Guy bob;
int bank = 100;
public Form1()
{
InitializeComponent();
bob = new Guy() { Cash = 100, Name = "Bob" };
joe = new Guy() { Cash = 50, Name = "Joe" };
UpdateForm();
}
public void UpdateForm() {
joesCash.Text = joe.Name + " has $" + joe.Cash;
bobsCash.Text = bob.Name + " has $" + bob.Cash;
bankCash.Text = "The bank has $" + bank;
}
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.");
}
}