Git Product home page Git Product logo

ruby-oop-cards's Introduction

ruby-oop-cards

Create a game of cards using ruby objects.

  1. Create a card class that, when you initialize it, creates an array of "cards" that are of value 1-52.

  2. Create a game class that uses the card class to play a game.

  • when you play the game, draw two cards from the deck.
  • if the player has the highest card, give them a point.
  • if the player doesn't have the highest card, deduct a point.
  • if the player's score is less than -2, end the game.
  1. Inside the game class, keep a record of each hand played in an instance variable array.

  2. show the score to the player

Hints:

Use a while loop for each turn of the game. Look in the solution/play.rb if you're not sure how to write the game loop Look in the solution class files if you forget the syntax of ruby classes

further

Ask the player for their name at the beggining of the game, and print it out at each turn. Example: "hello Ray, you have 10 points."

further

On each turn, ask the player if he wants to continue with the game. If he says no, end the game and output the final score.

further

Implement betting inside the game class. Before each turn allow the user to make a wager from his current points.

further

Change the card class to reflect an actual deck of cards. You can choose to make each card a class instance if you want. You will have to change the winning card logic. You can use these rules: https://en.wikipedia.org/wiki/High_card_by_suit

further

Implement a blackjack game.

ruby-oop-cards's People

Contributors

awongh avatar phangster 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.