Question: In java Im trying to read a file input from a scanner and am unsure how to go about it. Using two String stacks (CardStack)

In java Im trying to read a file input from a scanner and am unsure how to go about it. Using two String stacks (CardStack) I would like to read from file to see if two cards match from 2 lines of strings and if they do then return true, else false and have the while loop go through each stack.

/** * This class generates random */ import java.util.Scanner;

public class CardSolo { public static boolean matchCard (String cardA, String cardB) { // TODO: How will you know if CardA can be matched to cardB? Return true if the 2 cards match. if(cardA.equals(cardB)){ return true; } else return false; } public static void main(String [] args) { // Need 2 stacks. CardStack A = new CardStack(); CardStack B = new CardStack(); Scanner inputScanner = new Scanner(System.in); String inputCard; A.pushCard("Queen of spades"); A.pushCard("King of hearts"); A.pushCard("3 of Diamonds"); A.popCard(); System.out.println(A.getSize); A.printCardStack();

// while there is a card in the input. while (inputScanner.hasNext()) { inputCard = inputScanner.next(); // TODO: Simulate the process... } System.out.print("Number of piles is " + A.size() + ":"); A.printCardStack(); } }

file example:

6H 8S JS AC AS // stack A 6C 8S KC 7H 9C // Stack B

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!