Question: Please use Java Part I: Hyperbola Drawing create a program named Hyperbola.java This program uses the Graphics object in a DrawingPanel Make a program that

Please use Java

Part I: Hyperbola Drawing

create a program named Hyperbola.java

This program uses the Graphics object in a DrawingPanel

Make a program that draws the following picture

Please use Java Part I: Hyperbola Drawing create a program named Hyperbola.java

To help get you started, the following code creates a DrawingPanel object and then accesses the Graphics object in order to call drawLine. The below only makes two calls to drawLine, which produces an "X" shape. You will need to replace these calls with one loop (or two) that can produce the hyperbola pictures.

import java.awt.*; public class Hyperbola { // The width and height of the DrawingPanel. public static final int PANEL_SIZE = 444; // Right now this draws an X, but should draw two hyperbolas. public static void main(String[] args) { DrawingPanel panel = new DrawingPanel(PANEL_SIZE, PANEL_SIZE); Graphics g = panel.getGraphics(); g.drawLine(0, 0, PANEL_SIZE, PANEL_SIZE); g.drawLine(0, PANEL_SIZE, PANEL_SIZE, 0); } } 

Your hyperbola DrawingPanel should be 512 pixels wide and 512 pixels tall. The hyperbola in the lower left-hand corner has grid lines separated by 32 pixels, and the hyperbola in the upper right-hand corner has grid lines separated by 8 pixels.

Use class constants for the size of the drawing panel, and for the 8- and 32-pixel intervals of the hyperbolas. You must pick clear names for the class constants. Note that the sample code that draws an "X" uses a class constant for the size of the panel with the wrong value.

A properly implemented Hyperbola program shouldn't take more than 18-25 lines of code and one or two for loops.

Drawing Panel

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!