Advertisement
kmahadev

Rectangle class

Aug 25th, 2012
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1.  
  2. public class Rectangle extends Shape {
  3. //have to create objects
  4. Point a = new Point();
  5. Point b = new Point();
  6. Point c = new Point();
  7. Point d = new Point();
  8. Point Center = new Point();
  9.  
  10. public Rectangle() {
  11. // TODO Auto-generated constructor stub
  12. }
  13.  
  14. public Rectangle(double x, double y) {
  15. //super(x, y);
  16. // TODO Auto-generated constructor stub
  17. }
  18.  
  19. public Rectangle(Point a1, Point b1, Point c1, Point d1){
  20.  
  21. a.setX( a1.getX() );
  22. a.setY( a1.getY() );
  23.  
  24. b.setX( b1.getX() );
  25. b.setY( b1.getY() );
  26.  
  27. c.setX( c1.getX() );
  28. c.setY( c1.getY() );
  29.  
  30. d.setX( d1.getX() );
  31. d.setY( d1.getY() );
  32.  
  33. /*
  34. angThree.setX( three.getX() );
  35. angThree.setY( three.getY() );
  36.  
  37. angFour.setX( four.getX() );
  38. angFour.setY( four.getY() );
  39.  
  40. */
  41. Center.setX( ( ( a.getX() + b.getX() + c.getX() + d.getX() ) / 4 ) );
  42. Center.setY( ( ( a.getY() + b.getY() + c.getY() + d.getY() ) / 4 ) );
  43.  
  44. }
  45.  
  46.  
  47. @Override
  48. double calculateArea() {
  49. // TODO Auto-generated method stub
  50. return 0;
  51. }
  52.  
  53. @Override
  54. public String toString() {
  55. String output = "\nThe Co-ordinates of this Rectangle are: \n";
  56. output += "\tA = " + "( " + a.getX() + ", " + a.getY() + " )";
  57. output += "\tB = " + "( " + b.getX() + ", " + b.getY() + " )";
  58. output += "\tC = " + "( " + c.getX() + ", " + c.getY() + " )";
  59. output += "\tD = " + "( " + d.getX() + ", " + d.getY() + " )";
  60. return output;
  61. }
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement