Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. import java.util.Scanner;import ch06.lists.*;import support.cards.*;  
  2. public class CardHandCLI
{public static void main(String[] args){
Scanner scan = new Scanner(System.in);final int HANDSIZE = 5;int slot;
  3. Card card; // playing card
CardDeck deck = new CardDeck(); // deck of playing cards
  
ListInterface<Card> hand = new ABList<Card>(HANDSIZE); // user's hand
  4. deck.shuffle();
hand.add(deck.nextCard()); // deals 1st card and places into hand
  5. for (int i = 1; i < HANDSIZE; i++){System.out.println("\nYour hand so far:");
slot = 0;for (Card c: hand){System.out.println(slot + "\n " + c);
slot++;}System.out.println(slot);
  
card = deck.nextCard();System.out.print("Slot between 0 and " + i + " to put " + card + " > ");
slot = scan.nextInt();
hand.add(slot, card);}
  6. System.out.println("\nYour final hand is:");for (Card c: hand)System.out.println(" " + c);}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement