/*
  car.h: header for C equivalent of:

  class Car subclassof Vehicle
  {
      int         wheels default 4;          // only cars have wheels(?)
      double      fuel_max;                  // in litres
      double      fuel_cur default 0;        // in litres
      void method addfuel( double L );       // add L litres to the fuel tank.
  }
*/

typedef struct Car *Car;	    // all objects are pointers

// foreach inherited or new method, declare a method type definition
// note that every method, and hence method signature, takes "this" first.
// many of these are inherited from Vehicle, but called Car_METHOD and
// taking "Car this" not "Vehicle this"
typedef void   (*Car_move        )( Car this, double t );
typedef void   (*Car_print       )( Car this );
typedef void   (*Car_dispose     )( Car this );
typedef void   (*Car_addfuel     )( Car this, double t );

struct Car
{
	// FIRST, Vehicle fields in same order, with Car_METHOD typenames
	char *         isa;            // attributes
        char *         name;
        Vector2        pos;
        Vector2        dir;
        double         speed;
        int            people_cur;
        int            people_max;
	Car_move       move;            // methods
	Car_print      print;
	Car_dispose    dispose;         // deconstructor

	// SECOND, new Car fields
        int            wheels;          // only cars have wheels(?)
        double         fuel_cur;        // in litres
        double         fuel_max;        // in litres
        Car_addfuel    addfuel;         // add some fuel to the fuel tank.
};

extern Car new_Car( char *name, Vector2 pos, Vector2 dir, double speed, int people_cur, int people_max, int wheels, double fuel_cur, double fuel_max );
extern void init_Car( Car c, char * name, Vector2 pos, Vector2 dir, double speed, int people_cur, int people_max, int wheels, double fuel_cur, double fuel_max );
extern Car alloc_Car( void );
