Question: Java - Data structures and algorithms VI. Matching Game Consider a matching game in which you have a list of random integer values between 10

Java - Data structures and algorithms

Java - Data structures and algorithms VI. Matching Game Consider a matchinggame in which you have a list of random integer values between10 and 99. You remove from the list any pair of consecutiveintegers that match. If first integer has digits xly1 and the secondinteger has digits x2y2 the match is found if any ofthe followingis true xi is the same as x2 x1 is the sameas y2 yl is the same as x2 yl is the sameas y2 If all integer values are removed, you win. You areallowed to shuffle the integer values up to 5 times to increase

VI. Matching Game Consider a matching game in which you have a list of random integer values between 10 and 99. You remove from the list any pair of consecutive integers that match. If first integer has digits xly1 and the second integer has digits x2y2 the match is found if any ofthe following is true xi is the same as x2 x1 is the same as y2 yl is the same as x2 yl is the same as y2 If all integer values are removed, you win. You are allowed to shuffle the integer values up to 5 times to increase the probability of finding more matches For example consider the following sequence of integers 70 82 43 23 89 12 43 84 93 17 The pair 70 and 82 does not match in either digit and so cannot be removed, next check 82 and 43, no match either. Next check 43 and 23, there is a match, so both values are removed. Continue checking for pairs from 89 which is the value after the removed pair. Once you finish the first pass the following sequence remains 70 82 89 12 93 17 Now return to the beginning of the list and check the pairs again. After the second pass the following sequence remains 70 12 93 17 Now return to the beginning of the list and check for the pairs again. This time no matches were found, so shuffle the list and try again. You are allowed to shuffle maximum 5 times Your Task: 1. Write a program that simulates this game (the skeleton is provided for you) a. initializeList generates numbers two-digit integers between 10 and 99 inclusively. The generated integers must be stored in ArrayList theNumbers using an instance of Listlterator b. Then using another instance of Listlterator, scan the list and remove matching pairs of values c. After each pass use an instance of Iterator to display the remaining content of the list 2. A sample run of the program and a UML diagram are provided 3. Make sure that the output is correct (see Sample Runs below)

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!