Reputation: 1
Hey I am trying to create a constructor so I can display the name and balance of a test account, but i'm not sure what to do. any help would be greatly appreciated, as I am new to programmin, and haven't been doing it for long.
public class Account
{
public Account (string Name, decimal balance);
public string name;
private decimal balance;
public string GetName()
{
return name;
}
static decimal MaxPayInAmount = 10000;
public bool PayInFunds(decimal amount)
{
if (amount < 0)
{
return false;
}
if (amount > MaxPayInAmount)
{
return false;
}
balance = balance + amount;
return true;
}
public bool SetName(string inname)
{
if (inname == "")
return false;
name = inname;
return true;
}
public Account(string inName)
{
name = inName;
}
public decimal GetBalance()
{
return balance;
}
}
Upvotes: 0
Views: 8096
Reputation: 8111
Your constructor does not have a method body. Use this instead:
public Account (string name, decimal balance)
{
this.name = name;
this.balance = balance;
}
Also you should follow some naming conventions (e.g. you made one parameter with capital letter and one in lowercase)
Upvotes: 5