Coder Social home page Coder Social logo

simetro's Introduction

Simetro

The ultimate metro trip planner

It's your job to calculate the total number of stops between two Metro stations.

Step 1 - Connect the CSS file

Add a link tag to the head of layout.erb

Step 2 - Define a trip route

When visiting http://localhost:4567/trip in the browser, Sinatra responds with a 404.

Create a get route to respond to get requests to /trip

Create an instance variable @num_stops, and set it equal to the number of stops between the start and end stations.

Click here for a hint 1. get the index of the start station from `metro` at `params[:line]`
2. get the index of the end station from `metro` at `params[:line]` 3. Subtract them and set them equal to `@num_stops`

Note: Sinatra will not render numbers.

(If you're testing this out before creating the view)

get '/' do
  1 # must be "1"
end

Step 3 - Create a trip view

Create a new file in views/trip.erb. To show the trip results.

Bonus !

Allow the user to select any two stops, without selecting a line. Calculate the total number of stops between the two stations, and tell the user which station to switch lines at.

simetro's People

Contributors

bgalladian avatar jshawl 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.