Modifying a Class

class MarbleJar
   MarbleJar(int black, int white);  // initializes jar contents
   String DrawMarble ( );          // draws and returns color
   void AddMarble (String color);  // adds marble to jar
   Boolean IsEmpty ( );                 // returns true if empty
   int myNumberBlack, myNumberWhite; // marbles in the jar
   int myRandom ( );                 // random number generator
Suppose the jar has also 100 red marbles. Draw three at a time. In 100 trials how many times are the three marbles the same color? What percent of the time?

In this problem you will have to modify the class Copy this file to your directory and rename it Write an additional construct to accept three parameters. Will you have to modify any functions? If you do, be sure that your Lab A still works correctly when you call instead of Now, modify your client LabA, renaming it as lab C, to draw three marbles at a time, compare, and tabulate results.

Continue to:  Unit 5 / Prev / Next