Coder Social home page Coder Social logo

restaurant-tycoon's Introduction

Restaurant Tycoon Object Relationship Practice.

Congrats! You've been hired to build out an app for the booming restaurant business! The base version of the app will allow users to search out restaurants and their locations around the city. When you get done, you can move on to the super bonus version but not until the base version is done.

If you are not sketching out your domain, and thinking about single source of truth, you should be!

Topics

  • Classes vs Instances
  • Variable Scope ( Class, Instance, Local )
  • Object Relationships
  • Arrays and Array Methods
  • Class Methods

Notes

Your goal is to build out all of the methods listed in the deliverables. Do your best to follow Ruby best practices. For example, use higher-level array methods such as map, select, and find when appropriate in place of each

We've provided you with a console that you can use to test your code. To enter a console session, run ruby tools/console.rb from the command line. You'll be able to test out the methods that you write here. Take a look at that file to see how you can pre-define variables and create object instances, rather than manually doing it in every single console session.

Deliverables

Build the following methods on the Restaurant class

  • Restaurant.all
    • Returns all Restaurant instances
  • Restaurant#locations
    • Returns an array of all Locationss of this particular Restaurant instance
  • Restaurant#total_rent
    • Returns the total amount this Restaurant pays for all of its Locations
  • Resturant#create_location
    • Creats a new Location instance for this particular Restuarant

Build out the following methods on the Location class

  • Location.all
    • Returns an array of all Location instances, irrespective of the Restaurant each Location belongs to
  • Location.all_addresses
    • Returns an array of the address of all Location instances.

SUPER BONUS MODE

Add a third class into the mix: an Employee. Each location can have many employees, while each employee belongs to a location.

Build out the following methods on the Employee class

  • Employee.all
    • Returns an array of each Employee instance, irrespective of which Restaurant they work for
  • Employee.average_pay
    • Returns the average pay of all employees, irrespective of which Restaurant they work for

Build out the following methods on the Restaurant class

  • Restaurant#employees
    • Returns an array of each Employee instance that works for this Restaurant
  • Restaurant#total_pay
    • Returns the total amount this Restaurant pays out to all of its employees
  • `Restaurant#total_expenes
    • Returns the total amount this Restaurant pays out to all of its employees AND in rent

Build out the following methods on the Location class

  • Location#hire_employee
    • Creates a new Employee instance for this Location

restaurant-tycoon's People

Contributors

critsmet 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.