在Java中使用ASCII水平打印扑克牌

在Java中使用ASCII水平打印扑克牌,java,Java,我有一个扑克游戏,使用自定义卡对象和检查价值。。。胡说八道。。。所有这些都是有效的,我所遇到的麻烦完全是表面上的 我在下面插入的代码是一个自定义方法,调用该方法时将打印卡片card.value()调用0-13之间的值作为卡的数值,card.suit()调用1-4作为卡的数值 **使用我现有的代码,是否可以让它打印水平而不是垂直的手?我缺少什么 public static void printCard(Card card){ System.out.println("┌─────────┐"

我有一个扑克游戏,使用自定义卡对象和检查价值。。。胡说八道。。。所有这些都是有效的,我所遇到的麻烦完全是表面上的

我在下面插入的代码是一个自定义方法,调用该方法时将打印卡片card.value()调用0-13之间的值作为卡的数值,card.suit()调用1-4作为卡的数值

**使用我现有的代码,是否可以让它打印水平而不是垂直的手?我缺少什么

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└─────────┘");              
}
公共静态无效打印卡(卡片){
System.out.println(“┌─────────┐");
如果(卡值()<10)
System.out.printf(“│%D│“,card.value()+1);
否则如果(card.value()==10)
System.out.printf(“│%s│“,“J”);
else if(card.value()==11)
System.out.printf(“│%s│“,“Q”);
否则如果(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│              │");
如果(card.suit()==1)
System.out.printf(“\n│       %C│“,”\u2663');
否则如果(card.suit()==2)
System.out.printf(“\n│       %C│“,”\u2666');
否则如果(card.suit()==3)
System.out.printf(“\n│       %C│“,”\u2665');
其他的
System.out.printf(“\n│       %C│“,”\u2660');
System.out.println(“\n│              │");
System.out.println(“│              │");
如果(卡值()<10)
System.out.printf(“│             %D│“,card.value()+1);
否则如果(card.value()==10)
System.out.printf(“│             %s│“,“J”);
else if(card.value()==11)
System.out.printf(“│             %s│“,“Q”);
否则如果(card.value()==12)
System.out.printf(“│             %s│“,“K”);
else if(card.value()==13)
System.out.printf(“│             %s│“,“A”);
System.out.println(“\n└─────────┘");              
}

谢谢!

一个简单的方法是在for循环中分别打印卡片的每一行

public static void printCards(List<Card> cards) {
    // Print the first line
    for(Card card : cards) System.out.print("┌────┐ ");
    System.out.println();

    // Print the second line
    for(Card card : cards) System.out.print("│%s   │ ", card.getPrintableValue());
    System.out.println();

    // ... and so on
}
现在,逐行打印卡片列表

public static void printCards(List<Card> cards) {
    // For each line to be printed
    for(int i = 0; i < Card.TEMPLATE.length; i++) {
        // For each card to be printed
        for(Card card : cards) {
            // Print that line of the card
            System.out.println(String.valueOf(card.getPrintableMatrix()[i])); 
        }
    }
}
公共静态无效打印卡(列表卡){
//对于要打印的每一行
对于(int i=0;i
一种简单的方法是在for循环中分别打印卡的每一行

public static void printCards(List<Card> cards) {
    // Print the first line
    for(Card card : cards) System.out.print("┌────┐ ");
    System.out.println();

    // Print the second line
    for(Card card : cards) System.out.print("│%s   │ ", card.getPrintableValue());
    System.out.println();

    // ... and so on
}
现在,逐行打印卡片列表

public static void printCards(List<Card> cards) {
    // For each line to be printed
    for(int i = 0; i < Card.TEMPLATE.length; i++) {
        // For each card to be printed
        for(Card card : cards) {
            // Print that line of the card
            System.out.println(String.valueOf(card.getPrintableMatrix()[i])); 
        }
    }
}
公共静态无效打印卡(列表卡){
//对于要打印的每一行
对于(int i=0;i
5张卡在垂直堆叠中打印,因为它通过每行打印。我希望它为手水平打印“ASCII”卡…基本上所有5张卡都在同一9行上。5张卡在垂直堆叠中打印,因为它通过每行打印。我希望它打印“ASCII”“手牌水平排列……基本上所有5张牌都在相同的9行上。用一些轻微的Tweek,这就解决了我的问题。谢谢!用一些轻微的Tweek,这就解决了我的问题。谢谢!