For this assignment you will be creating a GUI-based implementation of the kid T
ID: 3547951 • Letter: F
Question
For this assignment you will be creating a GUI-based implementation of the kid
To find multi-path route in this graph from 1or s to 18 or t i need to induced this graph to less nodes. Can you induced graph by relying assumption, we contract each group(s1, s2, ....) in G into one or two nodes in our new induced graph and set up direcExplanation / Answer
// import needed classes and packages import java.util.Scanner; import java.text.NumberFormat; import java.io.IOException; import java.util.Locale; import java.text.DecimalFormat; public class Program2 {public static void main(String[] args) throws IOException { //Declare Variables //Creates the cards based on their suite Card heartCard; Card diamondCard; Card spadeCard; Card clubCard; int countingPlays = 0; Scanner keyboard = new Scanner(System.in); //Allows Input //creates the cardPile array called DeckOfCards CardPile deckOfCards = new CardPile(); //Creates Player1's Card Pile CardPile player1Pile = new CardPile(); //Creates Player2's Card Pile CardPile player2Pile = new CardPile(); //Creates the cards to fill the array (1-14 of hearts/diamonds/spades/clubs). for(int i = 2; i < 15; i++) { char heart = 'u0003'; char diamond ='u0004'; char spade = 'u0005'; char club = 'u0006'; deckOfCards.add(heartCard = new Card(heart, i)); deckOfCards.add(diamondCard = new Card(diamond, i)); deckOfCards.add(spadeCard = new Card(spade, i)); deckOfCards.add(clubCard = new Card(club, i)); } //prints out the deck of Cards System.out.println("Deck Of Cards: " + deckOfCards); //shuffles the cards deckOfCards.shuffle(); //Prints out the deck of cards after they are shuffled System.out.println("Deck of Cards after shuffled: " + deckOfCards); //Checking the size of the Deck System.out.println("" + deckOfCards.size()); //Takes the deckOfCards and splits them up into 2 piles for Player1 and Player2 for(int i = 0; i < 26; i++) { player1Pile.add(deckOfCards.getTopCard()); player2Pile.add(deckOfCards.getTopCard()); } //Prints out the deck of Cards and then the player 1's pile and player 2's pile System.out.println("Deck of Cards after removing cards into two piles: " + deckOfCards); System.out.println("Player 1's Cards: " + player1Pile); System.out.println("Player 2's Cards: " + player2Pile); //checking the size of each players Pile System.out.println("" + player1Pile.size()); System.out.println("" + player2Pile.size()); //Prints the header for the game System.out.println("Lets have a war!!!"); System.out.println(" Player 1 Player 2"); System.out.println(" -------- --------"); //Testing tricky spot where the getTopCard removes a the topcard /* Card removedTopCard = player1Pile.getTopCard(); System.out.println("Getting player1Pile: " + removedTopCard); player1Pile.add(removedTopCard); System.out.println("Player1Pile is " + player1Pile); System.out.println("Player1Pile size is " +player1Pile.size()); */ //Starts the game of War try { //do while the sizes of the player piles are greater than 0. do { //gets the top cards of each players Pile Card player1RemovedTopCard = player1Pile.getTopCard(); Card player2RemovedTopCard = player2Pile.getTopCard(); //Compares the 2 cards to test which is bigger. If player 1's card is smaller than player 2 is the winner if(player1RemovedTopCard.compareTo(player2RemovedTopCard)Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.