Comments (2)
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blackjack.