In this assignment, you will utilize the MarbleJar class (see MarbleJar.h and MarbleJar.cpp) in order to simulate series of marble drawings. In particular, your simulations will allow you to collect data and hopefully solve the following puzzle:
Suppose a jar has an arbitrary mixture of black and white marbles. As long as there are at least two marbles in the jar, draw two random marbles and
Is it possible that the marble drawing process go on forever? Furthermore, if you are told the initial contents of the jar, can you predict the final outcome?
- if they are the same color, throw them both away and add a brand new black marble to the jar.
- if they are different colors, throw away the black one and return the white marble to the jar.
Write a C++ program named puzzle.cpp that will help you solve the puzzle. Your program should prompt the user for the initial contents of the jar and create a corresponding MarbleJar object. It should then repeatedly draw two marbles from the jar and perform the appropriate action based on the colors of the drawn marbles. If the process ends (with less than two marbles in the jar), then the final contents of the jar should be displayed. For example:
ANALYSIS: Once you have your program working, answer the following questions: