still new to cobra, i have difficulties with inheritance. I want an abstract class BoxOrPoint from which i want to inherit Box and Point. Box should get additional methods that are not present at BoxOrPoint. So this is my code so far
class BoxOrPoint is abstract
var _location as List<of number>
cue init(location as List<of number>)
base.init
assert location.count == 3
_location = location
get location from var
def centerOfMass as List<of number> is abstract
def totalMass as number is abstract
class Point inherits BoxOrPoint
var _mass as number
cue init(location as List<of number>, mass as number)
base.init(location)
_mass = mass
def centerOfMass as List<of number>
return base.location
def totalMass as number
return _mass
The compiler tells me that an error occures at line 24 because
- Code: Select all
Member "totalMass" also exists in the base class. YOu must specify "is override" or "is new", or change the name
When i add an "is new" modifier to the def totalMass, the compiler tells me that Point does not implement the inherited abstract member BoxOrPoint.TotalMass().
Any suggestions how to fix this code?
Thanks!