Circle - } //end of calcArea method //setRadius method...

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

View Full Document Right Arrow Icon
public class Circle { //define fields double radius; String colour; //constructor public Circle(double rad) { //assign parameter r to field rad radius = rad; colour = colour; } //end of constructor //getCircum method public double getCircum() { //calculate circumference double circum = 2 * Math.PI * radius; //return the result return circum; } //end of getCircum //calcArea Method public double calcArea() { //calculate area double area = Math.PI * Math.pow(radius,2); //return the result return area;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } //end of calcArea method //setRadius method public void setRadius(double r) { if (r<1) { System.out.println("Error! illegal value for radius"); } // end of if loop else { radius = r; System.out.println("Radius set to" + radius); } //end of else loop }// end of setRadius method //getRadius method public double getRadius() { // get radius double rad = radius; //return the result return radius; } //end of getRadius method } //end of class Circle...
View Full Document

This document was uploaded on 04/14/2010.

Ask a homework question - tutors are online