-1
This is the code of my class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Banco_Exercicio1
{
public class Conta
{
public string Titular { get; set; }
public double Saldo { get; set; }
public int Numero { get; set; }
public Conta(String nome)
{
Titular = nome;
}
public double Depositar(double Valor)
{
Saldo += Valor;
return Saldo;
}
public virtual void Saca(double Valor)
{
Saldo -= Valor;
}
}
public class ContaPoupanca : Conta
{
public override void Saca(double Valor)
{
base.Saca(Valor + 0.10);
}
}
}
This is the code of my form:
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 Banco_Exercicio1
{
public partial class Form1 : Form
{
public Conta conta;
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
conta = new Conta ("Victor")
{
Numero = 1 ,
Saldo = 0
};
TBtextoTitular.Text = conta.Titular;
TBtextoNumero.Text = Convert.ToString(conta.Numero);
TBtextoSaldo.Text = Convert.ToString(conta.Saldo);
}
private void deposito_Click(object sender, EventArgs e)
{
conta.Depositar(Convert.ToDouble(TBtextoValor.Text));
TBtextoSaldo.Text = Convert.ToString(conta.Saldo);
}
}
}
I’m making the following mistake:
Banco_exercicio1.Account does not contain a constructor that takes 0 Arguments"
How can I fix?
Even shared in the last link, post the content as the link may become disabled.
– user3628
What a mistake you’re making?
– Math
@brasofilo - My fault. Corrected.
– Leonardo Otto
since
ContaPoupanca
inherits fromConta
, it needs to have a constructor that gets at least the string name.– Roger Barretto
Managed to solve the problem?
– Miguel Angelo