Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA PROGRAMMING VI. Matching Game Consider a matching game in which you have a list of random integer values between 10 and 99. You remove
JAVA PROGRAMMING
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
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