Advertisement
Ricarte

Retangulo

Feb 5th, 2023
958
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. public class Retangulo {
  2.  
  3.     private Ponto p1;
  4.     private Ponto p2;
  5.  
  6.     public Ponto getP1() {
  7.         return p1;
  8.     }
  9.  
  10.     public void setP1(Ponto p1) {
  11.         this.p1 = p1;
  12.     }
  13.  
  14.     public Ponto getP2() {
  15.         return p2;
  16.     }
  17.  
  18.     public void setP2(Ponto p2) {
  19.         this.p2 = p2;
  20.     }
  21.  
  22.     public Retangulo(Ponto ponto1, Ponto ponto2){
  23.         this.p1 = ponto1;
  24.         this.p2 = ponto2;
  25.     }
  26.  
  27.     public Retangulo(Ponto ponto2){
  28.         this.p2 = ponto2;
  29.     }
  30.  
  31.     public double calcArea(){
  32.        double eixoX;
  33.        double eixoY;
  34.        eixoX = this.p1.getX() * this.p2.getX();
  35.        eixoY = this.p1.getY() * this.p2.getY();
  36.       return eixoX * eixoY;
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement