Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ex;
- import java.util.Scanner;
- public class Rectangle {
- private int x1, y1;
- private int x2, y2;
- private int x3, y3;
- private int x4, y4;
- public Rectangle(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
- this.x1 = x1;
- this.y1 = y1;
- this.x2 = x2;
- this.y2 = y2;
- this.x3 = x3;
- this.y3 = y3;
- this.x4 = x4;
- this.y4 = y4;
- }
- public int s () {
- int a = y2 - y1;
- int b = x3 - x2;
- int s = a * b;
- return s;
- }
- public int p () {
- int a = y2 - y1;
- int b = x3 - x2;
- int p = a * 2 + b * 2;
- return p;
- }
- public int same_point (Rectangle rectangle) {
- int count_same_point = 0;
- if (rectangle.x1 == x1 && rectangle.y1 == y1) count_same_point++;
- if (rectangle.x2 == x2 && rectangle.y2 == y2) count_same_point++;
- if (rectangle.x3 == x3 && rectangle.y3 == y3) count_same_point++;
- if (rectangle.x4 == x4 && rectangle.y4 == y4) count_same_point++;
- return count_same_point;
- }
- @Override
- public boolean equals(Object obj){
- if (obj == this) return true;
- return false;
- }
- @Override
- public String toString() {
- return "x1: " + x1 + " y1: " + y1 + " x2: " + x2 + " y2: " + y2 + " x3: " + x3 + " y3: " + y3 + " x4: " + x4 + " y4: " + y4;
- }
- public static void main(String[] args) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement