Advertisement
Guest User

Circle.java

a guest
Feb 26th, 2022
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. import java.awt.Color;
  2.  
  3. public class Circle extends Rectangle {
  4.     public int radius;
  5.  
  6.     public Circle() {
  7.         super(6, 6, 0, Color.CYAN);
  8.         radius = 3;
  9.     }
  10.  
  11.     public Circle(int radius, int length, Color color) {
  12.         super((2*radius), (2*radius), 0, color);
  13.         this.radius = radius;
  14.     }
  15.    
  16.     public Circle(int newX, int newY, int newRadius) {
  17.         super(newX, newY, 0, 0);
  18.         radius = newRadius;
  19.     }
  20.  
  21.     public int getRadius() {
  22.         return radius;
  23.     }
  24.  
  25.     public void setRadius(int radius) {
  26.         this.radius = radius;
  27.     }
  28.  
  29.     public int calcArea() {
  30.         return (int) Math.ceil(3.14 * radius * radius);
  31.     }
  32.    
  33.     public DrawFigure drawFigure() {
  34.         DrawFigure circle1 = new DrawFigure(3, radius, 0);
  35.         return circle1;
  36.     }
  37.  
  38.     public String toString() {
  39.         return "Radius = " + radius + " \n" + super.toString();
  40.     }
  41.    
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement