I'm reading Caelum's handout on C # and object orientation, and I put the following code in Conta.cs :
namespace Banco
{
class Conta
{
public int numero;
public string nome;
public double saldo;
public bool Sacar(double valor)
{
if (this.saldo >= valor)
{
this.saldo -= valor;
return true;
}
return false;
}
}
}
You have the Account class with the Take method. It says that to instantiate an object has to do the following:
private void button1_Click(object sender, EventArgs e)
{
Conta r = new Conta();
r.numero = 1;
r.nome = "Flano";
r.saldo = 300;
if (r.Sacar(250.0)) {
MessageBox.Show("Operação realizada com sucesso!");
} else {
MessageBox.Show("Saldo insuficiente!");
}
}
I understand how everything works, I just do not know where to put this button.