Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 14, Problem 3PC
Program Plan Intro

WatchMe Applet

Program plan:

  • Include necessary header files.
  • Define a class “WatchMeApplet”.
    • Declare and Initialize the necessary variables.
    • Define a method “init()”.
      • Declare a method “setBackground()” to set a background color.
      • Declare a method “addMouseListener()” to add a mouse listener to this applet.
      • Declare a method “addMouseMotionListener()” to add a mouse listener to this applet.
    • Define a method “paint()” to present  a component on the display.
      • Call the method “paint()” using the keyword “super”.
      • Call the method “setColor()” to set a color to an empty eyes.
      • Call the method “drawOval()” to draw a first eye.
      • Call the method “drawOval()” to draw a second eye.
      • Call the method “fillOval()” to draw a first pupils.
      • Call the method “fillOval()” to draw a second pupils.
  • Define a class “MyMouseListener”.
    • Define a method “mouseExited()”.
      • Assign a value to the respective variables.
      • Call the method “repaint()”to clear the surface of the components and then calls the “paint()” method.
  • Define a class “MyMouseMotionListener”.
    • Define a method “mouseMoved()”.
      • Assign a value to the respective variables.
      • Call the method “repaint()”to clear the surface of the components and then calls the “paint()” method.

Blurred answer
Students have asked these similar questions
ne: ID: A 7. A game is played by moving a game piece left or right along a horizontal game board. The board consists of spaces of various colors, as shown. The circle represents the initial location of the game piece. Yellow Black Green Green Red Yellow Yellow Black Black Black The following algorithm indicates how the game is played. The game continues until the game is either won by landing on the red space or lost when the piece moves off either end of the board. Step 1: Place a game piece on a space that is not red and set a counter to 0. Step 2: If the game piece is on a yellow space, move the game piece 3 positions to the left and go to step 3. Otherwise, if the game piece is on a black space, move the game piece 1 position to the left and go to step 3. Otherwise, if the game piece is on a green space, move the game piece 2 positions to the right and go to step 3. Step 3: Increase the value of the counter by 1. Step 4: If game piece is on the red space or moved off the end of the…
Slot Machine Simulation- I need to get answer in Pseudocode A slot machine is a gambling device that the user inserts money into and then pulls a lever (or presses a button). The slot machine then displays a set of random images. If two or more of the images match, the user wins an amount of money, which the slot machine dispenses back to the user. Design a program that simulates a slot machine. When the program runs, it should do the following: Ask the user to enter the amount of money he or she wants to insert into the slot machine. Instead of displaying images, the program will randomly select a word from the following list: Cherries, Oranges, Plums, Bells, Melons, Bars The program will select and display a word from this list three times. If none of the randomly selected words match, the program will inform the user that he or she has won $0. If two of the words match, the program will inform the user that he or she has won two times the amount entered. If three of the words…
OpenGL programming (c++) The program should generate a triangle that should move in response to the left mouse button being held down and the mouse moved. The figure should stop at the defined window boundaries (N,S,E,W) making sure that the entire figure is always present in your window.

Chapter 14 Solutions

Starting Out with Java: From Control Structures through Data Structures (3rd Edition)

Ch. 14.2 - Prob. 14.11CPCh. 14.3 - Prob. 14.12CPCh. 14.3 - Prob. 14.13CPCh. 14.3 - Prob. 14.14CPCh. 14.3 - Prob. 14.15CPCh. 14.4 - Prob. 14.16CPCh. 14.4 - Prob. 14.17CPCh. 14.5 - Prob. 14.18CPCh. 14.5 - Prob. 14.19CPCh. 14.5 - Prob. 14.20CPCh. 14.5 - Prob. 14.21CPCh. 14.5 - Prob. 14.22CPCh. 14.5 - Prob. 14.23CPCh. 14.5 - Prob. 14.24CPCh. 14.5 - What Graphics class methods do you use to perform...Ch. 14.6 - Prob. 14.26CPCh. 14.6 - Prob. 14.27CPCh. 14.6 - Prob. 14.28CPCh. 14.6 - Prob. 14.29CPCh. 14.6 - Prob. 14.30CPCh. 14.7 - Prob. 14.31CPCh. 14.7 - Prob. 14.32CPCh. 14.7 - Prob. 14.33CPCh. 14.7 - Prob. 14.34CPCh. 14.8 - Prob. 14.35CPCh. 14.8 - Prob. 14.36CPCh. 14.8 - Prob. 14.37CPCh. 14.8 - Prob. 14.38CPCh. 14 - Prob. 1MCCh. 14 - Prob. 2MCCh. 14 - Prob. 3MCCh. 14 - Prob. 4MCCh. 14 - When using Swing to write an applet, you extend...Ch. 14 - Prob. 6MCCh. 14 - Prob. 7MCCh. 14 - Prob. 8MCCh. 14 - Prob. 9MCCh. 14 - Prob. 10MCCh. 14 - Prob. 11MCCh. 14 - Prob. 12MCCh. 14 - Prob. 13MCCh. 14 - Prob. 14MCCh. 14 - Prob. 15MCCh. 14 - Prob. 16MCCh. 14 - Prob. 17MCCh. 14 - Prob. 18MCCh. 14 - Prob. 19MCCh. 14 - Prob. 20MCCh. 14 - Prob. 21MCCh. 14 - Prob. 22MCCh. 14 - Prob. 23TFCh. 14 - Prob. 24TFCh. 14 - Prob. 25TFCh. 14 - Prob. 26TFCh. 14 - Prob. 27TFCh. 14 - Prob. 28TFCh. 14 - Prob. 29TFCh. 14 - Prob. 30TFCh. 14 - Prob. 31TFCh. 14 - Prob. 32TFCh. 14 - Prob. 33TFCh. 14 - Prob. 34TFCh. 14 - Prob. 35TFCh. 14 - Prob. 1FTECh. 14 - Prob. 2FTECh. 14 - Prob. 3FTECh. 14 - Prob. 4FTECh. 14 - Prob. 5FTECh. 14 - Prob. 6FTECh. 14 - Prob. 1AWCh. 14 - Prob. 2AWCh. 14 - Prob. 3AWCh. 14 - Prob. 4AWCh. 14 - Prob. 5AWCh. 14 - Prob. 6AWCh. 14 - Prob. 1SACh. 14 - Prob. 2SACh. 14 - Prob. 3SACh. 14 - Prob. 4SACh. 14 - Prob. 5SACh. 14 - Prob. 6SACh. 14 - Prob. 7SACh. 14 - Prob. 8SACh. 14 - Prob. 9SACh. 14 - Prob. 1PCCh. 14 - House Applet Write an applet that draws the house...Ch. 14 - Prob. 3PCCh. 14 - Thermometer Applet Write an applet that displays a...Ch. 14 - Prob. 5PCCh. 14 - Prob. 6PCCh. 14 - Prob. 7PCCh. 14 - Prob. 8PCCh. 14 - Prob. 9PC
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr