For this project, you will use the bag of integers from Section 4.4. The bag includes the

Question:

For this project, you will use the bag of integers from Section 4.4. The bag includes the grab method from Figure 4.16 on page 229. Use this class in an applet that has three components:

1. A button

2. A small text field

3. A large text area

Each time the button is clicked, the applet should read an integer from the text field and put this integer in a bag. Then a random integer is grabbed from the bag, and a message is printed in the text area—something like “My favorite number is now ... .”

FIGURE 4.16 Implementation of a Method to Grab a Random Element Implementation public int grab( ) int i; // A random value between 1 and the size of the bag IntNode cursor; if (manyNodes =- 0) throw new IllegalStateException(

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: