import java.util.Scanner;
public class HotelTest{
public static void main(String[]ars) {
int x1,y1,w,h,x,y;
Scanner sc=new Scanner(System.in);
x1=sc.nextInt();
y1=sc.nextInt();
w=sc.nextInt();
h=sc.nextInt();
x=sc.nextInt();
y=sc.nextInt();
Rectangle re=new Rectangle(x1,y1,w,h);//构造对象
System.out.println(“area=”+re.getArea(w,h));//引用函数1
re.Contains(x,y); //引用函数2
}
}
class Rectangle{
public int x,y,w,h; //把长方形的数据引入
public Rectangle(int x1,int y1,int x2,int y2)
{
x=x1;y=y1;w=x2;h=y2; //定义长方形
}
public double getArea(double w,double h)
{
double s; //求面积,并返回s
s=w*h;
return s;
}
public void Contains(int a,int b)
{
if(this.x<a&&this.y>b) //判断点是否在长方形内
System.out.println("("+a+","+b+")"+"在长方形("+this.x+","+this.y+"),"+"w="+w+","+"h="+(int)h+"内");
else
System.out.println("("+a+","+b+")"+"在长方形("+this.x+","+this.y+"),"+"w="+w+","+"h="+(int)h+"外");
}
}
/1、编写合适的构造函数初始化一个矩形;
2、编写计算矩形面积的方法getArea();
3、编写计算判断矩形是否包含点的方法Contains(int x,int y)./