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 CaixaEletronico
{
    public partial class Form1 : Form
    {
        private Conta novaConta;
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Conta contaGuilherme = new Conta();
            contaGuilherme.Numero = 1;
            contaGuilherme.Deposita(1500.0);
            Cliente clienteGuilherme = new Cliente("Guilherme");
            clienteGuilherme.idade = 18;
            contaGuilherme.Titular = clienteGuilherme;
            bool sacou = contaGuilherme.Saca(300.0);//testando idade
            if (sacou)
            {
                MessageBox.Show("Saldo da Conta do Guilherme após saque: " + contaGuilherme.Saldo);
            }
            else
            {
                MessageBox.Show("Não foi possível sacar da conta do Guilherme");
            }
        }
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
        }
       public void Form1_Load(object sender, EventArgs e)
        {
            this.novaConta = new Conta();
            Cliente Titular =  new Cliente("vitor");
            this.novaConta.Deposita(250.0);
            this.novaConta.Numero = 1;
            Titular.idade = 25;
            textoNome.Text = Titular.Nome;
            textoNumero.Text = Convert.ToString(novaConta.Numero);
            textoSaldo.Text = Convert.ToString(novaConta.Saldo);
        }
        private void btnDepositar_Click(object sender, EventArgs e)
        {
           double valorDepostitar = Convert.ToDouble(textoDepositar.Text);
            this.novaConta.Deposita(valorDepostitar);
            textoSaldo.Text = Convert.ToString(this.novaConta.Saldo);
            textoDepositar.Text = "";
        }
        private void button2_Click(object sender, EventArgs e)
        {
            double valorSacar = Convert.ToDouble(textoSacar.Text);
            this.novaConta.Saca(valorSacar);
            textoSaldo.Text = Convert.ToString(novaConta.Saldo);
            textoSaldo.Text = "";
        }
    }
}
/////////o erro dá nessa pag
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaixaEletronico
{
    class Conta
    {
        public int Numero { get; set; }
        public Cliente Titular { get; set; }
        public double Saldo { get; private set; }
        public void Deposita(double valorASerDepositado)
        {
            if (valorASerDepositado > 0)
            {
                this.Saldo += valorASerDepositado;
            }
        }
        public bool Saca(double valorASerSacado)
        {
            if (valorASerSacado > this.Saldo || valorASerSacado < 0)
            {
                return false;            }
            else
            {
                if (this.Titular.EhMaiorDeIdade())
                {
                    this.Saldo -= valorASerSacado;
                    return true;
                }
                else
                {
                    if (valorASerSacado <= 200)
                    {
                        this.Saldo -= valorASerSacado;
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
        }
        public void Transfere(double valor, Conta destino)
        {
            this.Saca(valor);
            destino.Deposita(valor);
        }
        public double CalculaRendimentoAnual()
        {
            double saldoNaqueleMes = this.Saldo;
            for (int i = 0; i < 12; i++)
            {
                saldoNaqueleMes = saldoNaqueleMes * 1.007;
            }
            double rendimento = saldoNaqueleMes - this.Saldo;
            return rendimento;
        }
    }
}