Circle - // Returns the calculated value of the area

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

View Full Document Right Arrow Icon
//****************************************************************************** // Circle.java Author: Lewis/Loftus // // Represents a circle. //****************************************************************************** / import java.text.*; i public class Circle extends Shape { protected double radius; protected static DecimalFormat form = new DecimalFormat("0.##"); //--------------------------------------------------------------------------- // Sets up the circle by entering its radius //--------------------------------------------------------------------------- public Circle(double rad) { radius = rad; } //--------------------------------------------------------------------------- // Returns the double value of the radius //--------------------------------------------------------------------------- public double getRadius() { return radius; } //---------------------------------------------------------------------------
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // Returns the calculated value of the area //---------------------------------------------------------------------------public double computeArea() { return radius * radius * Math.PI; } //---------------------------------------------------------------------------// Returns the calculated value of the perimeter (circumference) //---------------------------------------------------------------------------public double computePerimeter() { return 2 * radius * Math.PI; } //---------------------------------------------------------------------------// Returns pertinent information about the circle //---------------------------------------------------------------------------public String toString() { return "Circle: radius is " + form.format(radius) + "\ncircumference is " + form.format(computePerimeter()) + ", area is " + form.format(computeArea()); } }...
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