Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. package at.ac.campuswien.shape;
  2.  
  3. public class Circle extends Shape {
  4. private int centerX;
  5. private int centerY;
  6. private int radius;
  7.  
  8. public Circle(int x,int y,int rad){
  9. this.centerX = x;
  10. this.centerY = y;
  11. this.radius = rad;
  12. }
  13.  
  14. public Circle(int x,int y,int rad,String color, String name, boolean stroke){
  15. this.centerX = x;
  16. this.centerY = y;
  17. this.radius = rad;
  18. super.setColor(color);
  19. super.setName(name);
  20. super.setStroked(stroke);
  21. }
  22.  
  23. public double getArea(){
  24. return (radius*radius)*3.1415;
  25. }
  26.  
  27. public double getPerimeter(){
  28. return 2*3.1415*radius;
  29. }
  30.  
  31. public String toString(){
  32. return "centerX = "+centerX+" centerY= "+centerY+" Radius= "+radius+" Area= "+ this.getArea()
  33. +" Perimeter= "+ this.getPerimeter();
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement