Git Product home page Git Product logo

js-object-oriented-daily-lunch-web-022018's Introduction

Daily Lunch Lab

Objectives

  • Build a domain model with class relations using JavaScript iterator methods
  • Use JavaScript to write query methods on our classes to answer questions about data in the store

Instructions

In the following lab, we will be modeling all the models for The Daily Deli. The Daily Deli delivers daily lunches to different offices around US Cities. A customer orders a meal and it is delivered to the office of the customer's employer. So The Daily Deli relates a customer to a meal based on whether that meal was delivered to a customer. The employer of a customer is associated with the deliveries and meals ordered by its employees.

You will be modeling the following:

Customer class:

  • new Customer() — initialized with both name, and an instance of an employer; returns a JavaScript object that has attributes of id, employerId, and name
  • meals() - returns all of the meals that a customer has had delivered
  • deliveries() — returns all of the deliveries that customer has received
  • totalSpent() - returns the total amount that the customer has spent, as a function of the cost of the meals he has had delivered

Meal class:

  • new Meal() — initialized with title and price; returns an object that has attributes oftitle, price, and id
  • deliveries() - returns all of the deliveries that delivered the particular meal.
  • customers() - returns all of the customers who have had the meal delivered.
  • byPrice() - A class method that orders the meals by their price. Use the static keyword to write a class method.

Class methods are methods that are not called on an instance of the class, but on the class itself, for example Meal.byPrice() is a class method as it is called on the Meal class. You can write a class method simply by preceding a method on a class with JavaScript's static keyword. You can read more about class methods in JavaScript here.

Delivery class:

  • new Delivery() — initialized with meal and customer; returns an object that has attributes of mealId, customerId, and id
  • meal() - returns the meal associated with the delivery
  • customer() - returns the customer associated with the delivery

Employer class:

  • new Employer() — initialized with name; returns an object that has attributes of name and id
  • employees() - returns a list of customers employed by the employer
  • deliveries() - returns a list of deliveries ordered by the employer's employees
  • meals() - returns a list of meals ordered by the employer's employees. The method is to not return the same meal multiple times.
  • mealTotals() - returns a JavaScript object displaying each respective meal id ordered by the employer's employees. The keys of the JavaScript object are the meal ids and associated with each meal id is a value. For example, employerOne.mealTotals() returning an object of {1: 4, 2: 3} would mean that the meal with id of 1 was ordered by employerOne's employees four times, and the meal with id of 2 was ordered by employerOne's employees three times.

js-object-oriented-daily-lunch-web-022018's People

Contributors

gj avatar jeffkatzy avatar realandrewcohn avatar danielseehausen avatar alexgriff avatar

Watchers

 avatar Rishikesh Tirumala avatar James Cloos avatar  avatar Victoria Thevenot avatar  avatar Joe Cardarelli avatar Katie Burke avatar Sara Tibbetts avatar The Learn Team avatar Sophie DeBenedetto avatar  avatar Antoin avatar  avatar  avatar Amanda D'Avria avatar  avatar  avatar Nicole Kroese  avatar Lisa Jiang 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.