Code Monkey home page Code Monkey logo

car_lab's Introduction

Prototype Body Shop

Implement the following

The idea of this lab is to get you comfortable with writing and implementing prototypes and constructors. We will also review testing in the lab.

Phase I

Our car should have the following:

  • make
  • model
  • year
  • state
  • color
  • previous_owners
  • current_owner

As a default a new Car should have the following values:

  • previous_owners should be an empty array, [].
  • current_owner: should be the manufacturer (ford,honda,toyota).
  • state should be off.

We should also be able to do the following with our car.

  • Car#sale, we should be able to sell a car to someone, which should update the current_owner and previous_owners array.

  • Car#paint, which should take a new color and update the color of the car to be new color.

Phase II

Implement and test the following methods:

  • Car#start should change the state of the car to on.
  • Car#off should change the state to off.
  • Car#driveTo, it should console.log "driving to <destination>", but only if the car state is on. Note: this method needs to take a destination param.
  • Car#park only if the car is off and if it's off console.log parked!!.

Phase III

Add the following property to the constructor:

  • passengers

it should default to an empty array.

Implement the following methods:

  • Car#pick_up should take a name and console.log that you are "driving to 'pick up <friend>'", but only if the car is on. It should also update the passangers array to include the new passanger.
  • Car#dropOff it should take a name and remove them from the passengers array, but only if they are in the array. It should also only drop them off if the car is on.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.