3 ms·
OOP doesn't force you do do car.drive(). You can have an abstract agent class/interface with virtual "drive(Car c)" method. The method would be overriden by AI
by skocznymroczny 5y ago
OOP doesn't force you do do car.drive().
You can have an abstract agent class/interface with virtual "drive(Car c)" method. The method would be overriden by AIAgent, HumanAgent etc.
The car itself would have more basic behavior, such as "accelerate()", "turnLeft()", "turnRight()"
- temporama1 5y agoKill me now
- bruce343434 5y agoI think you are over engineering it. The way I imagine it: Car {float throttle, float brake, float wheel} inherits PhysicalObject {velocity, mass, position} Agent.accelerate(Car c){ c.throttle++; } Agent.drive(Car c){ ... accelerate(c); ... } Human inherits Agent
- orwin 5y agoInterface is the best way to do a clean job in this case.
- jhgb 5y ago> You can have an abstract agent class/interface with virtual "drive(Car c)" method. The method would be overriden by AIAgent, HumanAgent etc. Is that a convoluted way of saying "use multiple dispatch", or am I reading it wrong?