Coder Social home page Coder Social logo

This is a test issue! about blackjack HOT 2 OPEN

Bodacious avatar Bodacious commented on July 16, 2024
This is a test issue!

from blackjack.

Comments (2)

knoxjeffrey avatar knoxjeffrey commented on July 16, 2024

Hey guys, here's my attempt at analysing the blackjack game in an OOP way:

CARD
has suits
has values

DECK
has cards

PLAYER
has a name
holds cards
method to stick or hit

DEALER
holds cards
method to stick or hit

BANK
has a starting amount
method to adjust the account

HAND_HELD
has player and dealer cards
method to calculate player and dealer hands
method to check if hand is bust
method to compare hands
method to display the cards

BLACKJACK GAME
has decks
accepts bet input
method to deal cards to dealer and player
method to remove cards from deck
method to replenish deck

GAME_INPUT_VALIDATION
method to check if y or n is chosen
method to check if player input a number

The game_input_validation wouldn't be a class, would that be a module? I can also see that both the player and dealer can hold cards and should also decide to stick or hit. Would I make the dealer inherit from player seeing as they are both a type of player (the dealer would also need a name in this case). The logic behind the decision to stick or hit is different for a player and a dealer so that behaviour would be overwritten in that case?

from blackjack.

knoxjeffrey avatar knoxjeffrey commented on July 16, 2024

I made some changes to the classes and I've finished the game off now - https://github.com/knoxjeffrey/blackjack/blob/master/blackjack_oop.rb

from blackjack.

Related Issues (1)

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.