add existing documentation
This commit is contained in:
44
doc/sample/Vehicle.im
Executable file
44
doc/sample/Vehicle.im
Executable file
@@ -0,0 +1,44 @@
|
||||
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
|
||||
Reference in New Issue
Block a user