Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. package ex;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Rectangle {
  6. private int x1, y1;
  7. private int x2, y2;
  8. private int x3, y3;
  9. private int x4, y4;
  10.  
  11. public Rectangle(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
  12. this.x1 = x1;
  13. this.y1 = y1;
  14. this.x2 = x2;
  15. this.y2 = y2;
  16. this.x3 = x3;
  17. this.y3 = y3;
  18. this.x4 = x4;
  19. this.y4 = y4;
  20. }
  21.  
  22. public int s () {
  23. int a = y2 - y1;
  24. int b = x3 - x2;
  25. int s = a * b;
  26. return s;
  27. }
  28.  
  29. public int p () {
  30. int a = y2 - y1;
  31. int b = x3 - x2;
  32. int p = a * 2 + b * 2;
  33. return p;
  34. }
  35.  
  36.  
  37. public int same_point (Rectangle rectangle) {
  38. int count_same_point = 0;
  39. if (rectangle.x1 == x1 && rectangle.y1 == y1) count_same_point++;
  40. if (rectangle.x2 == x2 && rectangle.y2 == y2) count_same_point++;
  41. if (rectangle.x3 == x3 && rectangle.y3 == y3) count_same_point++;
  42. if (rectangle.x4 == x4 && rectangle.y4 == y4) count_same_point++;
  43.  
  44. return count_same_point;
  45. }
  46.  
  47. @Override
  48. public boolean equals(Object obj){
  49. if (obj == this) return true;
  50. return false;
  51. }
  52.  
  53. @Override
  54. public String toString() {
  55. return "x1: " + x1 + " y1: " + y1 + " x2: " + x2 + " y2: " + y2 + " x3: " + x3 + " y3: " + y3 + " x4: " + x4 + " y4: " + y4;
  56. }
  57.  
  58. public static void main(String[] args) {
  59.  
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement