summaryrefslogtreecommitdiffstats
path: root/Java/BlackJack/Card.java
blob: f4b2df43c6905b1d3d8deda40770a782d47d62ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
public class Card {

  // data member
  private int facePointValue;
  private String faceValue;
  private int points;
  private String suit;
  private int suitPointValue;


  
  // Constructors
  //accepts suit and face
  public Card (String inFace, String inSuit) {
    
	  switch(inFace){ //Reasoning for the switch is that working with strings as values in a comparision game will only casue problems, it must be converted to a sensable value
		  case "King": //all face cards are 10. 10 is also 10 (for obvious reasons)
		  case "king":
		  case "Joker":
		  case "joker":
		  case "Queen":
		  case "queen":
		  case "Jack":
		  case "jack":
		  case "10":
		  case "ten":
		  case "Ten":
		  facePointValue = 10;
		  break;
		  //these comparisions are the worst, but its the best way I could figure out accounting for all reasonable inputs without using regex
		  case "9":
		  case "nine":
		  case "Nine":
		  facePointValue = 9;
		  break;
		  
		  case "8":
		  case "eight":
		  case "Eight":
		  facePointValue = 8;
		  break;
		  
		  case "7":
		  case "seven":
		  case "Seven":
		  facePointValue = 7;
		  break;
		  
		  case "6":
		  case "six":
		  case "Six":
		  facePointValue = 6;
		  break;
		  
		  case "5":
		  case "five":
		  case "Five":
		  facePointValue = 5;
		  break;

		  case "4":
		  case "four":
		  case "Four":
		  facePointValue = 4;
		  break;

		  case "3":
		  case "three":
		  case "Three":
		  facePointValue = 3;
		  break;
		  case "2":
		  case "two":
		  case "Two":
		  facePointValue = 2;
		  break;

		  case "1":
		  case "one":
		  case "One":
		  case "Ace":
		  case "ace":
		  facePointValue = 1;
		  break;
		  default:
		  System.out.println("User Input was Invalid! " + inFace + " Is not a valad card!");
		  System.exit(1);
		  
	  }

		  faceValue = inFace; //since all of the above is just for value finding and will crash if breaks, might as well just get inFace as the value.
	  switch(inSuit){
		  case "heart":
		  case "hearts":
		  case "Heart":
		  case "Hearts":
		  suitPointValue = 4;
		  break;
		  case "club":
		  case "clover":
		  case "Club":
		  case "Clover":
		  suitPointValue = 3;
		  break;
		  case "Diamond":
		  case "diamond":
		  suitPointValue = 2;
		  break;
		  case "spade":
		  case "spear":
		  case "shovel":
		  case "Spade":
		  case "Spear":
		  case "Shovel":
		  suitPointValue = 1;
		  break;
                  default:
                  System.out.println("User Input was Invalid! " + inSuit + " Is not a valad card!");

                  System.exit(1);
	  }
		  suit = inSuit; //ditto reasoning of last comment
	  
  }
//no suit or face? assume 4 of clovers
  public Card() {
    suitPointValue = 3;
    facePointValue = 4;
    suit = "Clover";
    faceValue = "4";
  }

// set & return
// set

//return 
public String getFaceValue(){
return figureName(facePointValue);
}

public String getFaceSuit(){
return figureSuit(suitPointValue);
}

public int getFaceNumericValue(){
return facePointValue;
}

public int getSuitNumericValue(){
return suitPointValue;
}


  public String figureName(int input) { 
	  switch(input){
	  
	  case 1:
	  return "One";
	  
	  
	  case 2:
	  return "Two";
	  
	
	  case 3:
	  return "Three";
	  
	  
	  case 4:
	  return "Four";
	  
	  case 5:
	  return "Five";
	  
	  case 6:
	  return "Six";
	  
	  case 7:
	  return "Seven";
	  
	  case 8:
	  return "Eight";
	  
	  case 9:
	  return "Nine";
	  
	  case 10:
	  return "Ten";
	  
	  case 11:
	  return "Jack";
	  
	  case 12:
	  return "Queen";
	  
	  case 13:
	  return "King";
	  
	  case 14:
	  return "Joker";
	  
	  default:
	  System.out.println("figureName does not take " + input + "as a valid input!");
	  return null;
	  }
    
  }

  public String figureSuit(int input) {
  switch(input){
	  case 1:
		  return "Hearts";
		  
	  case 2:
		  return "Clovers";
		  
	  case 3:
		  return "Diamonds";
		  
	  case 4:
		  return "Spade";
	  default:
		  System.out.println("figureSuit does not take" + input + "as a valid input!");
		  return null;
		  
  
  } 
  }

  public String compareCardValue(String card1Name, int card1Face, int card1Suit, String card2Name, int card2Face, int card2Suit) {
    
	  if(card1Face == card2Face){
	    if(card1Suit > card2Suit){
	    return card1Name;
	    } else {
	    return card2Name;
	    }
		   
	  }

	  if (card1Face > card2Face) {
          return card1Name;
	  } else {
	  return card2Name;
	  }
  }

}