Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class
- TestFrame {
- //VARIABLES
- private static Deck deck;
- private static Card card;
- private static Scanner scan;
- private final static String fileName = "cards.txt";
- static ArrayList<Card> cards = new ArrayList<>();
- private static void Load(){
- deck = new Deck();
- card = new Card();
- // Load in the card file so that we can work with the data from cards.txt internally rather than from the file constantly.
- try(FileReader fr = new FileReader(fileName);
- BufferedReader br = new BufferedReader(fr);
- Scanner infile = new Scanner(br)){
- int numOfCards = infile.nextInt();
- infile.nextLine(); // Do we need this? Yes we do. Illuminati confirmed.
- for(int i=0; i < numOfCards; i++){
- String value = infile.nextLine();
- String suit = infile.nextLine();
- Card newCard = new Card(value, suit);
- card.addCard(newCard);
- System.out.print(newCard.getValue());
- System.out.print(newCard.getSuit());
- System.out.println(" ");
- //Print out the object before cycling through again so we can see if it's working
- //We can use this to add then cards to the shuffle array at a later date
- }
- }
- ah
- 2h
- 3h
- 4h
- 5h
- 6h
- 7h
- 8h
- private static void displayAllCards(){
- Card[] cards = Card.getAll();
- for(Card c : cards){
- System.out.print(Card.getValue());
- System.out.print(Card.getSuit());
- System.out.println(" ");
- }
- }
- public static Card[] getAll(){
- Card[] brb = new Card[cards.size()];
- int tempCount = -1;
- for(Card c : cards){
- tempCount++;
- brb[tempCount] = c;
- }
- return brb;
- }
- card.addCard(newCard);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement