Rectangle.java


Dosyayı İndir
package com.godoro.geometry;

import java.io.Serializable;


public class Rectangle implements Serializable{
    
    private double width;
    private double height;

    public Rectangle(double width, double height) {
        this.width = width;
        this.height = height;
    }

    public Rectangle() {
    }
    
    
    public double getWidth(){
        return width;
    }
    public void setWidth(double width){
        if(width<0){
            this.width=-width;
        }else{
            this.width=width;
        }
//        if(width<0){
//            throw new IllegalArgumentException("Genişlik eksi olamaz "+width);
//        }
        this.width=width;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }
    
    public double getArea(){
        return width*height;
    }
    
    public double getPerimeter(){
        return 2*(width+height);
    }
}

				
Dosyayı İndir

Bu Sayfayı Paylaş:




Bu Sayfayı Paylaş:

İletişim Bilgileri

Takip Et

Her Hakkı Saklıdır. Bu sitede yayınlanan tüm bilgi ve fikirlerin kullanımından fibiler.com sorumlu değildir. Bu sitede üretilmiş , derlenmiş içerikleri, fibiler.com'u kaynak göstermek koşuluyla kendi sitenizde kullanılabilirsiniz. Ancak telif hakkı olan içeriklerin hakları sahiplerine aittir