补全public class exereisel{ intx,y; public exercisel (){} public exercisel (int x,int y){ —————————————————— } public exercisel (exercisel p){ —————————————————— } public exercise1 getLocation ( ){ exercisel p=______; //实例exercise1 对象 p,其坐标是(x,y) _______//返回对象 p } public String toString (){ return " (" +x+"," +y+")"; } public static void main ( String ] args ){ exercisel p=___________; System. out. println ("x=”+p.x+" y=" +p.y); System. out. println (" Location is" +p. getlocation () ); }
时间: 2023-09-27 18:06:52 浏览: 32
好的,这里是完整的代码:
```
public class exercisel {
int x, y;
public exercisel() {}
public exercisel(int x, int y) {
this.x = x;
this.y = y;
}
public exercisel(exercisel p) {
this.x = p.x;
this.y = p.y;
}
public exercise1 getLocation() {
exercise1 p = new exercise1();
p.x = this.x;
p.y = this.y;
return p;
}
public String toString() {
return " (" + x + "," + y + ")";
}
public static void main(String[] args) {
exercisel p = new exercisel(1, 2);
System.out.println("x=" + p.x + " y=" + p.y);
System.out.println("Location is" + p.getLocation());
}
}
```
其中,`exercise1` 类没有给出,你需要根据上下文自行推测其定义。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)