Git Product home page Git Product logo

oop-inheritance-car's Introduction

#Bodyshop Part 2

Cars are great and all, but now it's time to extend this system and make it handle more types of vehicles.

Remember TDD? This time, you'll have to make your own tests for each feature. In many work environments, you will be the one writing tests. As a reminder, here's the workflow:

  1. Read each feature below and think about what it's asking for.
  2. Create a test (in test.js) to test the feature
  3. Run the test
  4. Write / revise code (in Motorcycle.js/Truck.js) to pass test, if necessary
  5. Repeat 3 and 4 until you pass all tests
  6. Move on to the next feature (start back at step 1)

##Getting Started

  • Fork and clone the repository
  • Run npm install to install dependencies
    • npm run lint:js - lint JS
    • npm test - run test suite

Writing Tests

In order to write tests, it's recommended that you look back at the tests for Car.js and start following some of the examples in order to get a feel for how to structure tests. Take advantage of the following functions:

  • assert.strictEqual(val1, val2, 'msg') - strictly compares two primitive values
  • assert.deepEqual(val1, val2, 'msg') - strictly compares the properties of two objects or arrays
  • instanceof - compares an object and a constructor, and sees if the object is an instance of the constructor
  • success() - a helper method defined in test/helpers/success.js that provided a success message after test units

Submission

After you submit via pull request, make sure your Travis CI build passes. Note that since we did not provide you the tests, it's your responsibility to write correct tests and correct code.

Requirements

###Part 1 -- Trucks

Create a new constructor called Truck that inherits Car.

This should be done in the file called Truck.js, which requires Car.js for you to use. Additionally your truckTest.js will need to require Truck.js (already done for you).

Your Truck constructor should meet the following requirements. There should be at least one test for each bullet point below.

  • Must be an instance of Truck
  • Must be an instance of Car.
  • Must have the following constructor parameters:
    • make
    • model
    • year
    • color
    • passengers
  • Must default to 3 seats.

There should be tests for each one of the bullet points above.

###Part 2 -- Motorcycles

Create a new constructor called Motorcycle that inherits your Car constructor.

This should be done in the file called Motorcycle.js, which requires Car.js for you to use. Additionally your motorcycleTest.js will need to require Motorcycle.js (already done for you).

Your Motorcycle constructor should meet the following requirements. There should be at least one test for each bullet point below.

  • Must be an instance of a Motorcycle
  • Must be an instance of a Car
  • Must have the following parameters
    • make
    • model
    • year
    • color
    • passengers
  • Must default to 2 seats
  • Must be able to do a wheelie by calling wheelie(), but only if running.
    • If the wheelie is successful, return true and console.log the following: "Doing a sick wheelie!!". Otherwise return false.
    • This function should be attached to Motorcycle.prototype.

Licensing

  1. All content is licensed under a CC-BY-NC-SA 4.0 license.
  2. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].

oop-inheritance-car's People

Contributors

bhague1281 avatar kendradalley avatar xingped avatar

Watchers

James Cloos avatar  avatar

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.