Advertisement
kmahadev

Shape class

Aug 25th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. public abstract class Shape {
  2.  
  3. protected double area;
  4. protected int perimeter;
  5.  
  6. Point Center;
  7.  
  8. public Shape(){ // Just sets the center for the shape
  9. //have to create a point object first
  10. Center = new Point(0,0);
  11. //Center.setX(0);
  12. //Center.setY(0);
  13. }
  14.  
  15. public Shape(int x, int y){ // sets the center for the shape with the user input for the points
  16. //have to create a point object first
  17. Center = new Point(x, y);
  18.  
  19. //Center.setX(x);
  20. //Center.setY(y);
  21. }
  22.  
  23. abstract double calculateArea();
  24.  
  25. @Override
  26. public String toString() {
  27. return "The Center of shape is at: ( " + Center.getX() + ", " + Center.getY() + " )";
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement