誰か助けてください。カード クラスとデッキ クラスを作成しましたが、ハンド クラスの作成方法がわかりません。
これは、以下の私の Card クラスです。
package blackjack;
public class Card {
private int rank;
private int suit;
@Override
public String tostring() {
String result = "";
if (rank == 1) result = "Ace";
if (rank == 2) result = "Two";
if (rank == 3) result = "Three";
if (rank == 4) result = "Four";
if (rank == 5) result = "Five";
if (rank == 6) result = "Six";
if (rank == 7) result = "Seven";
if (rank == 8) result = "Eight";
if (rank == 9) result = "Nine";
if (rank == 10) result = "Ten";
if (rank == 11) result = "Jack";
if (rank == 12) result = "Queen";
if (rank == 13) result = "King";
if (suit == 1) result = result + " of Clubs ";
if (suit == 2) result = result + " of Diamonds ";
if (suit == 3) result = result + " of Hearts ";
if (suit == 4) result = result + " of Spades ";
return result;
}
public Card(int rank, int suit) {
this.rank = rank;
this.suit = suit;
}
}
これは私のデッキクラスです
package blackjack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
public class Deck {
private Random shuffles = new Random();
public ArrayList<Card> Deck = new ArrayList<Card>();
Random rand = new Random();
// private int numberOfCards = 52;
public Deck() {
for (int ranks = 1; ranks <= 13; ranks++) {
for (int suits =1 ; suits <= 4; suits++) {
Deck.add(new Card(ranks, suits));
//System.out.println(Deck.get(ranks) + "" +Deck.get(suits));
}
}
shuffle();
for (int i = 1; i < Deck.size(); i++) {
//int cardPosition2 = shuffles.nextInt(52);
//shuffle.nextInt(Deck.get(i);
System.out.println(Deck.get(i));
//System.out.println(cardPosition2);
//i++;
}
}
public void shuffle() {
Collections.shuffle(Deck);
}
public Card DrawCard() {
int cardPosition = shuffles.nextInt(Deck.size());
return Deck.remove(cardPosition);
}
public int TotalCardsLeft() {
return Deck.size();
}
public Card dealCard() {
// Deals one card from the deck and returns it.
if (Deck.size() == 52) {
shuffle();
}
Card temp;
temp = Deck.get(0);
Deck.remove(0);
return temp;
}
public Card getCard(int i) {
return Deck.get(i);
}
public Card remove(int i) {
Card remo = Deck.get(i);
Deck.remove(i);
return remo;
}
}
ハンドコールを手伝っていただければ、本当に助かります。