Advertisement
YauhenMardan

Untitled

Mar 7th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Point;
  3. import java.util.ArrayList;
  4.  
  5. public class Rectangle extends Polygon {
  6. // constructors
  7.  
  8. public Rectangle(
  9. Point refPoint,
  10. Point defPoint,
  11. Color borderColor,
  12. Color figureColor) {
  13. super(refPoint, defPoint, null , borderColor, figureColor);
  14. setAuxiliaryPoints(calculateAuxiliaryPoints(getRefPoint(),getDefPoint()));
  15. }
  16.  
  17. public Rectangle(Rectangle rectangle) {
  18. super(rectangle);
  19. }
  20.  
  21. //methods
  22.  
  23. private ArrayList<Point> calculateAuxiliaryPoints(Point refPoint,Point defPoint){
  24. ArrayList<Point> auxiliaryPoints=new ArrayList<>();
  25. auxiliaryPoints.add(refPoint);
  26. auxiliaryPoints.add(new Point(refPoint.x,defPoint.y));
  27. auxiliaryPoints.add(defPoint);
  28. auxiliaryPoints.add(new Point(defPoint.x,refPoint.y));
  29. return auxiliaryPoints;
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement