I need help with a code I'm working on about classes and inheritance.
I created a simple Class of base information
class BaseStuff
{
public string ownersName;
public int price;
public string location;
public int phone;
public string space;
public BaseStuff(string ownersName, int price, string location, int phone, string space)
{
this.ownersName = ownersName;
this.price = price;
this.location = location;
this.phone = phone;
this.space = space;
}
}
After that I tried creating anotehr class that inherit information on the "BaseStuff" class, but with an add of new information that's special to that spacific class (floor number and has elevator).
class Apartment : BaseStuff
{
public int floor;
bool hasElevator;
public Apartment(int floor, bool hasElevator, string ownersName, int price, string location, int phone, string space)
{
this.ownersName = ownersName;
this.price = price;
this.location = location;
this.phone = phone;
this.space = space;
this.floor = floor;
this.hasElevator = false;
}
}
I know this code is wrong since it's not how you make a class inherit information from another class, and I'm struggeling to get the "Apartment" class to inherit information from the "BaseStuff" Class.
What can I do to fix it?
Thanks!