Star - -public void draw(Graphics page...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // Author: Lewis and Loftus // // Solution to Programming Project 4.12 //******************************************************************** import java.awt.Graphics; import java.awt.Color; public class Star { private int points, size, x, y; //---------------------------------------------------------------- // Sets up this star using the specified information. //---------------------------------------------------------------- public Star (int numPoints, int radius, int xPoint, int yPoint) { points = numPoints; size = radius; x = xPoint; y = yPoint; } //---------------------------------------------------------------- // Draws the star.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: //----------------------------------------------------------------public void draw (Graphics page) { page.setColor (Color.white); switch (points) { case 4: page.drawLine (x-size, y-size, x+size, y+size); page.drawLine (x-size, y+size, x+size, y-size); break; case 5: page.drawLine (x, y, x, y-size); page.drawLine (x, y, x-size, y-size); page.drawLine (x, y, x+size, y+size); page.drawLine (x, y, x-size, y+size); page.drawLine (x, y, x+size, y-size); break; default: int shift = size / 3; page.drawLine (x-size, y, x+size, y); page.drawLine (x-size+shift, y-size, x+size-shift, y+size); page.drawLine (x-size+shift, y+size, x+size-shift, y-size); } } }...
View Full Document

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Ask a homework question - tutors are online