IsoscelesRightTriangle - canvas.drawLine(lowerLeftX,...

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

View Full Document Right Arrow Icon
import java.awt.Graphics; public class IsoscelesRightTriangle { // Data members protected int lowerLeftX, lowerLeftY; protected int base, height; protected Graphics canvas; public IsoscelesRightTriangle(Graphics theCanvas) { canvas = theCanvas; } public IsoscelesRightTriangle(int llX, int llY, int theLength, int theHeight, Graphics theCanvas) { canvas = theCanvas; lowerLeftX = llX; lowerLeftY = llY; base = theLength; height = theHeight; } public void draw() {
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: canvas.drawLine(lowerLeftX, lowerLeftY, lowerLeftX, lowerLeftY + height); canvas.drawLine(lowerLeftX, lowerLeftY + height, lowerLeftX + base, lowerLeftY + height); canvas.drawLine(lowerLeftX, lowerLeftY, lowerLeftX + base, lowerLeftY + height); } public void erase() { canvas.clearRect(lowerLeftX, lowerLeftY, base, height); } public double area() { double area = 0.5 * height * base; return area; } }...
View Full Document

This note was uploaded on 06/10/2011 for the course COMP 110 taught by Professor Stotts during the Spring '08 term at UNC.

Ask a homework question - tutors are online