Giter Site home page Giter Site logo

many_to_many_practice's Introduction

Deliverables

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.

Basic Class Methods and Properties

Task: Build out the methods and relationships for a Tourist model, a Landmark model, and a Trip model.

  • A Tourist has a name
  • A Landmark has a name and a city
  • A Tourist can visit many Landmarks.
  • A Landmark can be visited by many Tourists
  • A Trip belongs to a Tourist
  • A Trip belongs to a Landmark
  • A Tourist can take many Trips
  • A Landmark can have many Trips

Build the following methods on the Tourist class

  • Tourist.all
    • should return all of the Tourist instances
  • Tourist#name
    • returns the name of the given Tourist
  • Tourist.find_by_name(name)
    • given a string of a name, returns the first tourist whose name matches
  • Tourist#trips
    • returns an array of all the trips taken by the given Tourist
  • Tourist#landmarks
    • returns an array of all the landmarks for the given Tourist
  • Tourist#visit_landmark(landmark) should create a new trip for that tourist to the given landmark
  • Tourist#never_visited should return an array of all the landmarks this tourist has never traveled to

Build out the following methods on the Landmark class

  • Landmark.all
    • returns an array of all landmarks
  • Landmark.find_by_city(city)
    • returns an array of all landmarks in that city
  • Landmark#trips
    • returns an array of all the trips taken to a given landmark
  • Landmark#tourists
    • returns an array of all the tourists at a given landmark

Build out the following methods on the Trip class

  • Trip.all
    • returns an array of all trips
  • Trip#tourist
    • returns the tourist who has taken that trip
  • Trip#landmark
    • returns the landmark visited on the trip

many_to_many_practice's People

Contributors

paulnicholsen27 avatar raaynaldo 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.