java矩形类2



package com.javabase.sss;

//矩形类
public class Rects {
	private long Length1;  //长
	private long width1;   //宽
	
	
	
	public long getLength1() {
		return Length1;
	}
	//设置长度
	public void setLength1(long length1) {
		if(length1<=0) {
			 Length1 = 1;
			 return;
		}
			this.Length1 = length1;

		
	}
	public long getWidth1() {
		return width1;
	}
	//设置宽度
	public void setWidth1(long width1) {
		if(this.width1<=0) {
			 this.width1 = 1;
			 return;
		}
		this.width1 = width1;
	}
	
	public long getArea() {
		if(this.width1 <= 0 || this.Length1 <=0) {
			return 0;
		}else {
			return this.width1 * this.Length1;
		}
		
	}
	
	
	
	

}

















你可能感兴趣的:(java,java)