package question2;
/**
*
* @author wang
* @version 1.0
*
*/
public class Rectangle
{
private int l;
private int w;
/**
*
* @param l
* @param w
*/
public Rectangle(int l, int w)
{
this.l = l;
this.w = w;
}
/**
*
* @return int . the area of the rectangle
*/
public int area()
{
return l * w;
}
public static void main(String[] args)
{
Rectangle r1 = new Rectangle(8, 6);
System.out.println(r1.area());
Rectangle r2 = new Rectangle(7, 7);
System.out.println(r2.area());
}
}
JAVA LAB3 问题2-答案与解析
最新推荐文章于 2022-05-16 21:16:48 发布