Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Graphics;
- public class Square{
- public int x;
- public int y;
- public int a;
- public int b;
- public Square() {
- x=70;
- y=150;
- a=20;
- b = 30;
- }
- public Square(int x, int y, int a , int b){
- this.x=x;
- this.y=y;
- this.a=a;
- this.b = b;
- }
- public void drawSquare(Graphics g) {
- g.drawRect(x, y, a, b);
- }
- public void isSquare() {
- if(a == b)
- System.out.println("Квадрат");
- else
- System.out.println("Прямокутник");
- }
- public int CalculateArea() {
- return a*b;
- }
- public void CheckArea(Square ob) {
- if(CalculateArea() > ob.CalculateArea()) {
- System.out.println("Площа 1 більша");
- }
- else
- System.out.println("Площа 2 більша");
- }
- public double getLenght(Square ob) {
- return Math.sqrt((ob.x + ob.a/2 - x - a/2)*(ob.x + ob.a/2 - x - a/2) + (ob.y + ob.b/2 - y - b/2)*(ob.y + ob.b/2 - y - b/2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement