Already answered but I'll give more context.
You need to mark your method as static
:
static carFun(){ ...
This makes the method available as a 'Class Method'; right now, as you have defined it, it is an 'Object Method'. This means that you need to make an object out of the class Car
to be able to use it, which would be something like this:
var myCar = new Car();
myCar.carFun();
This way you instantiated an object and used a defined method for it. Marking it as static would make this approach not work. This is one of the many differences between a Class and an Object.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…