Created
February 27, 2016 07:32
-
-
Save addicted2sounds/02be009b95ddba772540 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.company; | |
| /** | |
| * Created by addicted on 27.02.16. | |
| */ | |
| public class Circle { | |
| private double radius; | |
| public double getCircumference() { | |
| return 2 * Math.PI * radius; | |
| } | |
| public void setCircumference(double circumference) { | |
| this.radius = circumference / (2 * Math.PI) ; | |
| } | |
| public Circle(double radius) { | |
| this.radius = radius; | |
| } | |
| public double getRadius() { | |
| return radius; | |
| } | |
| public void setRadius(double radius) throws IllegalArgumentException { | |
| if (radius < 0) { | |
| throw new IllegalArgumentException("Radius can't be negative"); | |
| } | |
| this.radius = radius; | |
| } | |
| public double getArea() { | |
| double area = Math.PI * Math.pow(radius, 2); | |
| return area; | |
| } | |
| public void setArea(double area) throws IllegalArgumentException { | |
| if (area < 0) { | |
| throw new IllegalArgumentException("Area can't be negative"); | |
| } | |
| radius = Math.sqrt(area / Math.PI); | |
| } | |
| public void print() { | |
| System.out.println("I'm a circle"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment