Advertisement
elrerag

3_0

Nov 16th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. package ejemplo;
  2.  
  3. public class Rectangulo {
  4.     private double lado1;
  5.     private double lado2;
  6.  
  7.     public Rectangulo(double lado1, double lado2) {
  8.         this.lado1 = lado1;
  9.         this.lado2 = lado2;
  10.     }
  11.  
  12.     public double getLado1() {
  13.         return this.lado1;
  14.     }
  15.  
  16.     public void setLado1(double lado1) {
  17.         this.lado1 = lado1;
  18.     }
  19.  
  20.     public double getLado2() {
  21.         return this.lado2;
  22.     }
  23.  
  24.     public void setLado2(double lado2) {
  25.         this.lado2 = lado2;
  26.     }
  27.    
  28.     public double getPerimetro(){
  29.         return (this.lado1 + this.lado2) * 2;
  30.     }
  31.    
  32.     public double getArea(){
  33.         return this.lado1 * this.lado2;
  34.     }
  35.  
  36.     @Override
  37.     public String toString() {
  38.         return "Rectangulo{" + "lado1=" + this.lado1 + ", lado2="
  39.                 + this.lado2 + '}';
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement