Files
ivy/doc/sample/Vehicle.im

45 lines
692 B
Plaintext
Raw Normal View History

2024-11-02 15:11:00 +00:00
package net.doorstuck.vehicles
protocol Vehicle
- startup
- shutdown
- nrWheels
- nrDoors
- turn(direction:dir)
- accelerate(direction:dir)
- velocity
end
class Car <Vehicle>
- startup
self.engineRunning = true
end
- shutdown
self.engineRunning = false
end
- nrWheels
^4
end
- nrDoors
^4
end
- turn(direction:dir)
self.currentDirection = dir
end
- accelerate(direction:dir)
match dir
#forward => self.currentVelocity += 1,
#backward => self.currentVelocity -= 1,
end
end
- velicity
^self.currentVelocity
end
end