Use the material from Section 10.3 to reimplement the animal-guessing program from Figure 9.8 as a JApplet.
Question:
Use the material from Section 10.3 to reimplement the animal-guessing program from Figure 9.8 as a JApplet. You’ll need to research additional details of the Java classes.
Transcribed Image Text:
FIGURE 9.8 The Animal-Guessing Program Java Application Program // FILE: Animal.java // This animal-guessing program illustrates the use of the binary tree node class. import edu.colorado.nodes.BTNode; // For BTNode
FIGURE 9.8 The Animal-Guessing Program Java Application Program // FILE: Animal.java // This animal-guessing program illustrates the use of the binary tree node class. import edu.colorado.nodes.BTNode; // For BTNode import java.util.Scanner; public class Animal { private static Scanner stdin = new Scanner(System.in); public static void main(String[ ] args) { BTNode root; instruct( ); root = beginningTree( ); do play(root); while (query("Shall we play again?")); System.out.println("Thanks for teaching me a thing or two."); } public static void instruct( ) I| The implementati on of this method is omitted write it yourself! public static void learn(BTNode current) || The implementation of this method is Self-Test Exercise 9. public static void play (BTNode current) { while (!current.isLeaf( )) { if (query(current.getData( ))) current = current.getleft(); else current = current.getRight( ); "); System.out.print("My guess is " + current.getData( ) + if (!query("Am I right?")) learn(current); else System.out.println("I knew it all along!"); }
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 88% (9 reviews)
import javaxswing import javaawt import javaawtevent public class AnimalGuessing extends JApplet implements ActionListener private static final long s...View the full answer
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
The Hampshire Company manufactures umbrellas that sell for $12.50 each. In 2014, the company made and sold 60,000 umbrellas. The company had fixed manufacturing costs of $216,000. It also had fixed...
-
You are the Chairperson of the Business Program at InterState Community College (ICC). Recently it has come to that attention of ICC Administration that there is a need for Project Management...
-
BACKGROUND You are an information analyst working for NEE. The company president has asked you to prepare a Quantitative analysis of financial, sales, and operations data to help determine which...
-
Complete the attached SWOT Worksheet using information from the Cotopaxi case. Use your SWOT Worksheet to help you answer the question: What should Davis Smith/Cotopaxi do (for company...
-
A local power commission sent a survey to homeowners to determine household power efficiency. Following is a list of major electrical appliances and their total kilowatt-hour (kWh) usage for one...
-
What function is performed by a local domain name server? What is the purpose of the cache in a local domain name server table?
-
Show how the Mohr's circles in Figure 2.17 can be used to interpret the transformed lamina stiffness \(\bar{Q}_{12}\). FIGURE 2.17 40 'n Q11 In- n> Q11 20 -U-
-
On December 31, 2012, when the market interest rate is 10%, OBrien Realty, Co., issues $800,000 of 7.25%, 10-year bonds payable. The bonds pay interest semiannually. Requirements 1. Determine the...
-
Orville walks 0.323 km due east. He then continues walking along a straight line, but in a different direction, and stops 0.220 km northeast of his starting point. How far did he walk during the...
-
Early in January 2020, Hopkins Company is preparing for a meeting with its bankers to discuss a loan request. Its bookkeeper provided the following accounts and balances at December 31, 2019. Except...
-
The java.lang.Math class provides a static method log(x), which returns the logarithm of x with a base that is approximately 2.718282..7This base is written e, and the logarithms with this base are...
-
Use the DefaultMutableTreeNode to reimplement one of these Chapter 9 projects: a. Expression trees (9.1) b. Bag of strings (9.10)
-
Find the areas of the parallelograms whose vertices are given. A(1, 0), B(0, 1), C(-1, 0), D(0, -1)
-
How is the client prevented from directly accessing the details of an instance of a class?
-
Design a maze in which there are starting positions that return Trapped when the starting position is Open.
-
The Unsorted List ADT is to be extended with a Boolean member function, IsThere, which takes as a parameter an item of type ItemType and determines whether there is an element with this key in the...
-
1. Change the specifications for the Sorted List ADT so that PutItem throws an exception if the list is full. 2. Implement the revised specifications in (a) using an array-based implementation. 3....
-
Read the code segment and fill in blank #28. 1. listData 2. predLoc->next 3. location->next 4. newNode->next 5. answer not shown 4 Class Unsorted Type { public: //all the prototypes go here. private:...
-
Cheryl incurred $8,700 of medical expenses in November 2016. On December 5, the clinic where she was treated mailed her the insurance claim form it had prepared for her with a suggestion that she...
-
The comparative statements of financial position of Menachem NV at the beginning and end of the year 2019 appear below. Net income of ¬34,000 was reported, and dividends of ¬23,000 were paid...
-
In this exercise, we examine how pipelining affects the clock cycle time of the processor. Problems in this exercise assume that individual stages of the datapath have the following latencies: Also,...
-
In this exercise, we examine how data dependences affect execution in the basic 5-stage pipeline described in Section 4.5. Problems in this exercise refer to the following sequence of instructions:...
-
In this exercise, we examine how resource hazards, control hazards, and Instruction Set Architecture (ISA) design can affect pipelined execution. Problems in this exercise refer to the following...
-
Direct materials Fixed manufacturing overhead costs Sales price Variable manufacturing overhead Direct labor Fixed marketing and administrative costs Units produced and sold during the quarter...
-
Provide documentation of a step by step training plan for a beta fish. What will be the primary reinforcer? How will you cue the behavior? What schedule of reminforcement will you use. What is the...
-
On May 1, Soriano Company reported the following account balances along with their estimated fair values: Items Carrying Amount Fair Value Receivables Inventory Copyrights Patented technology Total...
Study smarter with the SolutionInn App