私はカスタムカードオブジェクトを使用して価値をチェックするポーカーゲームを持っています... blah blah ...すべての作品と私が問題を抱えているのは厳密に化粧です。JavaのASCII水平を使用してポーカーハンドを印刷する
私が下に挿入したコードは、呼び出されたときにカードを印刷するカスタムメソッドです。スーツの値1-4を呼び出すcard.value()カードとcard.suit(の数値のために0-13から値を呼び出し)。
** 私の既存のコードを使用すると、垂直の代わりに手を水平に印刷できますか?私は何が欠けていますか?
public static void printCard(Card card){
System.out.println("┌─────────┐");
if(card.value() < 10)
System.out.printf("│%d │", card.value()+1);
else if(card.value() == 10)
System.out.printf("│%s │", "J");
else if(card.value() == 11)
System.out.printf("│%s │", "Q");
else if(card.value() == 12)
System.out.printf("│%s │", "K");
else if(card.value() == 13)
System.out.printf("│%s │", "A");
System.out.printf("\n│ │");
System.out.printf("\n│ │");
if(card.suit() == 1)
System.out.printf("\n│ %c │", '\u2663');
else if(card.suit() == 2)
System.out.printf("\n│ %c │", '\u2666');
else if(card.suit() == 3)
System.out.printf("\n│ %c │", '\u2665');
else
System.out.printf("\n│ %c │", '\u2660');
System.out.println("\n│ │");
System.out.println("│ │");
if(card.value() < 10)
System.out.printf("│ %d│", card.value()+1);
else if(card.value() == 10)
System.out.printf("│ %s│", "J");
else if(card.value() == 11)
System.out.printf("│ %s│", "Q");
else if(card.value() == 12)
System.out.printf("│ %s│", "K");
else if(card.value() == 13)
System.out.printf("│ %s│", "A");
System.out.println("\n└─────────┘");
}
ありがとうございます!
5枚のカードは、各行に印刷されるので、垂直スタックで印刷されます。 「ASCII」カードを水平に印刷したいのですが、基本的に同じ9行に5枚のカードがあります。 –