Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Circle{
- //Field
- private int radius;
- //Specified (parameterized) Constructor
- public Circle( int r ){
- radius = r;
- }
- //Accessor
- public int getRadius(){
- return radius;
- }
- //Mutator
- public void setRadius( int r ){
- radius = r;
- }
- //area - calculates and returns the area of the circle
- public double area(){
- return Math.PI * Math.pow( radius, 2 );
- }
- //circumference - calculates and returns the circumference of the circle
- public double circumference(){
- return 2 * Math.PI * radius;
- }
- //toString - returns a textually representative String of the Circle object
- public String toString(){
- return "This circle has a radius of " + radius;
- }
- //equals - returns true if two circle have the exact same radius
- public boolean equals( Circle other ){
- return this.getRadius() == other.getRadius();
- }
- }
Add Comment
Please, Sign In to add comment