Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4 . 1 Applied Lab: Card Applications In this lab, we will write an application to store a deck of cards in a linked list,
Applied Lab: Card Applications In this lab, we will write an application to store a deck of cards in a linked list, and then write methods to sort and shuffle the deck. Step : Copy your LinkedList Copy your completed LinkedList class from Lab into the LinkedList.java file below. Step : Implement the methods of the Card class Complete all methods of the Card class as described by the Javadoc comments. The class contains both a suit and a rank. A suit is one of the categories into which the cards of a deck are divided. The rank is the relative importance of the card within its suit. Note that the Card constructor must convert any rank and suit letters to uppercase. For the equals method, be sure to follow the steps outlined in Lesson If you did not learn how to implement the compareTo method in your prior course, read the tutorial here. Note that you are not allowed to add any additional methods or member variables to this class or you will not receive credit for this assignment. Step : Implement the methods of the CardApp class Complete all methods of the CardApp class in the CardApp.java file as described by the Javadoc comments. You may add as many methods as you would like to this file, but are not allowed to add any additional member variables. The CardApp program must prompt for and allow the user to enter the name of any input file as shown in the Example output below. Enter the name of a file containing a deck of cards: cardstxt Please open shuffled.txt and sorted.txt Goodbye! Implement the shuffle method as specified in the comments for shuffle After you have shuffled the deck of cards, write the result into a file named shuffled.txt Implement the sort method using bubble sort from Lesson First sort by suit in alphabetical order and then by rank from to A The pseudocode for bubble sort is as follows: for i up to and including length for j up to and including length i each pass make fewer comparisons if Aj Aj Aj Ajswap After you have sorted the deck of cards, write the result to a file named sorted.txt The CardApp.java file also contains the main method of the application. Use Develop mode to test your CardApp code along with your Card and LinkedList code. All input and output files must contain a list of cards, with each card stored on its own line. See the example files cardstxt and cardstxt for example file formats. Simple Shuffle Example: The below example is intended to help you verify that you understand how to shuffle the cards Before shuffling: H H H H H H H H H JH First and last swapped: JH H H H H H H H H H Swapped H and H JH H H H H H H H H H Swapped H and H JH H H H H H H H H H Swapped H and H JH H H H H H H H H H End first set of swaps JH H H H H H H H H H Swapped H and H JH H H H H H H H H H Swapped H and H JH H H H H H H H H H Swapped H and H JH H H H H H H H H H Swapped H and H JH H H H H H H H H H Swapped H and H JH H H H H H H H H H Swapped H and H JH H H H H H H H H H Swapped H and H JH H H H H H H H H H End second set of swaps After shuffling: JH H H H H H H H H H
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started