Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package OverloadOverride;
- public class Circle {
- public static final double DEFAULT_RADIUS = 8.8;
- public static final String DEFAULT_COLOR = "red";
- private double radius;
- private String color;
- public Circle() {
- radius = DEFAULT_RADIUS;
- color = DEFAULT_COLOR;
- }
- public Circle(double radius) {
- this.radius = radius;
- color = DEFAULT_COLOR;
- }
- public Circle(double radius, String color) {
- this.radius = radius;
- this.color = color;
- }
- public double getRadius() {
- return radius;
- }
- public void setRadius(double radius) {
- this.radius = radius;
- }
- public String getColor() {
- return color;
- }
- public void setCOlor(String color) {
- this.color = color;
- }
- public String toString() {
- return "Circle with radius = " + radius + " and color of " + color;
- }
- public double getArea() {
- return radius*radius*Math.PI;
- }
- public static void main(String args[]) {
- Circle b = new Circle();
- double f;
- f = b.getArea();
- System.out.println(f);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement