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
Question
Book Icon
Chapter 14, Problem 5PC
Program Plan Intro

Polygon Drawer

Program plan:

  • Include necessary header files.
  • Define a class “PolygonApplet”.
    • Declare and initialize the necessary variables.
    • Define a method “init()”.
      • Call the necessary methods to initialize the polygon.
    • Define a method “paint()”.
      • Call the method “setcolor()” using the graphics object “g”.
      • Call the method “drawRect()”using the graphics object “g”.
    • Define a method “line()”.
      • Call the method “getGraphics()” and assign the result into the object “g”.
      • Call the method “drawLine()” using the object “g”.
      • Call the method “dispose()” using the object “g”.
    • Define a method “polygon()”.
      • The “if” loop to check “count” is less than “2”.
        • True, return the value.
          • Call the method “getGraphics()” and assign the result into the object “g”.
          • The “if” loop to check “count” is equal to “2”.
            • True, call the method “drawLine()” using the object “g”.
          • Otherwise, call the necessary methods using the object “g” to draw a polygon.
    • Define a method “mousePressed()” to draw a polygon.
    • Define a method “mouseReleased()”.
    • Define a method “mouseClicked()”.
    • Define a method “mouseEntered()”.
    • Define a method “mouseExited()”.

Blurred answer
Students have asked these similar questions
Volume of Histogram: Imagine a histogram (bar graph). Design an algorithm to compute the volume of water it could hold if someone poured water across the top. You can assume that each histogram bar has width 1. EXAMPLE Input: {0, 0, 4, 0, 0, 6, 0, 0, 3, 0, 5, 0, 1, 0, 0, 0} (Black bars are the histogram. Gray is water.) Output: 26 0 0 4 0 0 6 0 0 3 0 5 0 1 0 0 0
URGENT!!! PLS HELP  {    int source,                                // DON'T EDIT THIS LINE        destination,                           // DON'T EDIT THIS LINE        weight;                                // DON'T EDIT THIS LINE}EDGE;                                         // DON'T EDIT THIS LINEtypedef struct{    int num_vertices,                          // DON'T EDIT THIS LINE        num_edges;                             // DON'T EDIT THIS LINE    EDGE *edges;                               // DON'T EDIT THIS LINE}GRAPH;                                        // DON'T EDIT THIS LINEGRAPH *init_graph(int vertices, int edges);    // DON'T EDIT THIS LINEvoid fill_graph(GRAPH *graph);                 // DON'T EDIT THIS LINE int is_cycle(/*DON'T FORGET TO EDIT THIS LINE*/);void Kruskals_MST(GRAPH *graph);               // DON'T EDIT THIS LINE int main() {     GRAPH *graph = init_graph(10, 14);         // DON'T EDIT THIS LINE    fill_graph(graph);                         // DON'T EDIT…
Computer Graphics: Using any existing 2D or 3D graphics library ( such as  Java 2D, Java 3D or OpenGL )  draw a scene featuring various elements. You are to choose one from the following categories: Promotion for some cause using Java 2D only. It must consist of :- at least three graphical elements - at least one composite graphical element- at least one (1)  textual element.

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
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781305480537
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT