Giter Site home page Giter Site logo

js-object-oriented-class-relations-lab-web-100817's Introduction

Class Relations Lab

Objectives

  • Use class syntax to construct objects
  • Use JavaScript iterator methods to build class relations

Instructions

In the following lab, we want to model our Scuber system in such a way that we can see all of the passengers related to a driver. A driver becomes related to a passenger when he takes a single trip. Only one passenger is associated with a trip -- the passenger who books, and pays for the trip on their phone.

Each class should be defined in such a way that it adds an incrementing id to each individual instance of the respective class. An object should also be added to the store upon being initialized.

Construct the following classes:

Driver class:

  • A driver has many trips, and has many passengers through trips.
  • new Driver() - initialized with a name; returns a JavaScript object that has attributes of id, and name
  • trips() - returns all of the trips that a driver has taken
  • passengers() - returns all of the passengers that a driver has taken on a trip

Passenger class:

  • A passenger has many trips, and has many drivers through trips.
  • new Passenger() - initialized with a name; returns a JavaScript object that has attributes of id, and name
  • trips() - returns all of the trips that a passenger has taken
  • drivers() - returns all of the drivers that has taken a passenger on a trip

Trip class:

  • A trip belongs to a driver and belongs to a passenger.
  • new Trip() - initialized with an instance of driver and an instance of passenger; returns a JavaScript that has attributes id, driverId, and passengerId
  • driver() - returns the driver associated with the trip
  • passenger() - returns the passenger associated with the trip

js-object-oriented-class-relations-lab-web-100817's People

Contributors

gj avatar jeffkatzy avatar meryldakin avatar slin12 avatar

Watchers

James Cloos 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.