summaryrefslogtreecommitdiffstats
path: root/Java/BlackJack/Hand.java
diff options
context:
space:
mode:
Diffstat (limited to 'Java/BlackJack/Hand.java')
-rw-r--r--Java/BlackJack/Hand.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/Java/BlackJack/Hand.java b/Java/BlackJack/Hand.java
new file mode 100644
index 0000000..a9fb174
--- /dev/null
+++ b/Java/BlackJack/Hand.java
@@ -0,0 +1,51 @@
+public class Hand {
+
+ // data member
+ private int[] cardsInHandFace= new int[22]; //the maximum possible hands size is 22, if you draw 22 aces you'll bust. Values as expected
+ private int[] cardsInHandSuit= new int[22]; //usual values
+ private int numCardsInHand;
+
+ // Constructors
+ //accepts suit and face
+ public Hand (int firstFace, int firstSuit, int secondFace, int secondSuit) {
+ cardsInHandFace[1] = firstFace;
+ cardsInHandSuit[1] = firstSuit;
+ cardsInHandFace[2] = secondFace;
+ cardsInHandSuit[2] = secondSuit;
+ //for some reason it wanted this, so I gave it. This code is total spaghetti and garbage. These assignments don't feel like they were ment to work with one another.
+ }
+
+// set & return
+// set
+
+//return
+public int calculateHandValue(){
+
+int value = 0;
+
+for(int i=0; i < cardsInHandFace.length;i++){
+value = value + cardsInHandFace[i];
+}
+return value;
+}
+
+public void showAllCards(){ //there is absolutely no reason this should return something. These constraints are bad and don't teach OOP well. None of this need be OOP at all as it just overcomplicates this to a maximal degree. A much better teaching for OOP would be making some small farming game in where you had animals to take care of. OOP would be useful there as you could easily generate personalities, needs, types, colors, etc for each animal as to make good use of OOP and its capabilities. Blackjack doesn't need nor have variation like that and thus does not need OOP. Due to the fact that each class has a private value to it, there is great redundancy in the amonut of values stored, therefore causing the application to use more RAM than it needs to. This is also difficult to keep track of because some of these methods (such as card name and value finding) are redundant and cannot easily work with one another due to the strange constraints in what methods we must use.
+
+ for(int i=1; i < cardsInHandFace.length + 1;i++){
+ System.out.print("Card Number " + i + "'s face is " + this.cardsInHandFace[i] + " and its suit is " + this.cardsInHandSuit[i]);
+ }
+
+}
+
+
+public void showOneCard(int input) { //fix to return something
+System.out.print("Card Number " + input + "'s face is " + this.cardsInHandFace[input] + " and its suit is " + this.cardsInHandSuit[input]);
+}
+
+public void hit(Card c) { //fix to return something
+ for(int i=0; i < cardsInHandFace.length;i++){
+ if(cardsInHandFace[i] == 0) {
+ cardsInHandFace[i] = c.getFaceNumericValue();
+ cardsInHandSuit[i] = c.getSuitNumericValue();
+ }}}
+}