I am trying to create a basic banking system to practice using classes, after creating the parent class "Account", I tried to create a "savings" class which will be the child class and inherit the attributes and methods, however, no matter what I look up nothing will tell me how to do this. I get errors such as "must declare a body because it is not marked abstract, extern or partial", and so on. I really don't know what to do to get it working, so I'm hoping someone here can help, here's my code:
public class Account { protected string name; protected string birthdate; protected string address; protected double balance; protected string status; protected string type; public Account(string customerName, string customerBirthdate, string customerAddress, int customerBalance) { name = customerName; birthdate = customerBirthdate; address = customerAddress; balance = customerBalance; status = "Ok"; type = "Basic"; } public void customerDetails() { Console.WriteLine("Name: {0}, Birthdate: {1}, Address: {2}", name, birthdate, address); } public void accountDetails() { Console.WriteLine("Balance: £{0}, Account Status: {1}, Account Type: {2}", Math.Round(balance, 2), status, type); } private void updateStatus() { if (balance < 0) { status = "Overdrawn"; } else if (balance > 0 ) { status = "Ok"; } } public void deposit(int amount) { balance += amount; updateStatus(); } public void withdraw(int amount) { balance -= amount; updateStatus(); } } public class Savings : Account { public Savings(string customerName, string customerBirthdate, string customerAddress, int customerBalance) : Account(customerName, customerBirthdate, customerAddress, customerBalance) { name = customerName; birthdate = customerBirthdate; address = customerAddress; balance = customerBalance; status = "Ok"; type = "Basic"; } } Thanks in advance if anyone can help me out!
basekeyword, not the name of the base class itself.public Savings(string customerName, string customerBirthdate, string customerAddress, int customerBalance) : base(customerName, customerBirthdate, customerAddress, customerBalance)