Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago