资源简介
本资源适用于初学者,在数组应用方面的题目
代码片段和文件信息
public class MyPoint {
private int x=0;
private int y=0;
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public MyPoint(){
this.x=0;
this.y=0;
}
public MyPoint(int xint y){
this.x=x;
this.y=y;
}
public int[]getXY(){
int []array={xy};
return array;
}
public void setXY(int xint y){
this.x=x;
this.y=y;
}
public String toString(){
String s=“(“+getX()+““+getY()+“)“;
return s;
}
public double distance(int xint y){
int xDiff = this.x-x;
int yDiff =this.y-y;
return Math.sqrt(xDiff*xDiff + yDiff*yDiff);
}
public double distance(MyPoint another){
int xDiff = this.x-another.x;
int yDiff =this.y-another.y;
return Math.sqrt(xDiff*xDiff + yDiff*yDiff);
}
public double distance(){
return Math.sqrt(x*x+ y*y);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-09-18 20:02 Assignment2-ex1\
文件 307 2018-09-18 20:02 Assignment2-ex1\.classpath
文件 391 2018-09-18 20:02 Assignment2-ex1\.project
目录 0 2018-09-18 20:02 Assignment2-ex1\.settings\
文件 603 2018-09-18 20:02 Assignment2-ex1\.settings\org.eclipse.jdt.core.prefs
目录 0 2018-09-26 20:04 Assignment2-ex1\bin\
文件 1835 2018-09-26 20:04 Assignment2-ex1\bin\MyPoint.class
文件 1721 2018-09-26 20:04 Assignment2-ex1\bin\TestMyPoint.class
目录 0 2018-09-18 21:08 Assignment2-ex1\src\
文件 887 2018-09-25 14:57 Assignment2-ex1\src\MyPoint.java
文件 1318 2018-09-25 14:57 Assignment2-ex1\src\TestMyPoint.java
- 上一篇:SSSBBB.slx
- 下一篇:强大交通灯控制
评论
共有 条评论