Skip to content

Instantly share code, notes, and snippets.

@lazywithclass
Last active December 3, 2015 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazywithclass/fae39321cfe9ec64004a to your computer and use it in GitHub Desktop.
Save lazywithclass/fae39321cfe9ec64004a to your computer and use it in GitHub Desktop.
// review programming-itro-1.js
// questions?
// no OOP, FP
// model a car
// break it up in units <-- !
// model a tyre
function spin(wheel) {
wheel.isSpinning = true;
return wheel;
}
function isFlat(wheel) {
return wheel.flat;
}
function inflate(wheel) {
wheel.flat = false;
return wheel;
}
// model an engine
function start(engine) {
engine.on = true;
return engine;
}
function stop(engine) {
engine.on = false;
return engine;
}
function isStarted(engine) {
return engine.on;
}
function wearOff(engine) {
engine.statusIndex = engine.statusIndex + 1;
return engine;
}
// model the steering wheel
function steer(steeringWheel, direction) {}
// put it all together in the car
// start the car
function start(car) {}
// query your modelled objects to understand the state of the whole thing
// come up with some function you might think would be useful
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment