Giter VIP home page Giter VIP logo

cc-w4-d2-homework's Introduction

Sinatra Homework - Rock Paper Scissors

Create a simple sinatra app to allow the user to play rock, paper, scissors in their browser.

  • You should be able to go to /rock/scissors and return the string "rock wins" to the page, for example.

  • You will need to write a bit of logic that compares the two hands and decides which one has won, and then use that in the route definition.

  • Next, create a models directory for your game logic class e.g. 'Game' and put all of the logic in there - there shouldn't be any logic left in the controller!

Extensions:

  • Add an ERB view file for returning the result of the game, rather than just sending a string.

  • Add a welcome page (and a route to get it) to explain the rules before the user picks their move. Add a link to this on the result view.

  • Add some CSS to either/both of your pages.

Further extension:

Think about how you might differentiate between the two people playing the game - currently we don't know WHO has won, just which hand. If we think of '/rock/scissors' as being Player 1 plays Rock, and Player 2 plays Scissors, how might we be able to give the feedback of 'Player 1 wins by playing Rock!' rather than just 'Rock wins!'?

cc-w4-d2-homework's People

Contributors

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