📄 point.java
字号:
// Chapter 6 Exercises 1 & 2
public class Point {
protected double x = 0.0;
protected double y = 0.0;
// Constructors:
public Point(){}
// Construct a Point from its coordinates:
public Point(double x, double y) {
this.x = x;
this.y = y;
}
// Construct a Point from another Point:
public Point(Point point) {
x = point.x;
y = point.y;
}
// Method to return a point defined relative to this
// point in coordinates:
public Point add(Point z) {
return new Point(x+z.x,y+z.y);
}
// Overrides the method inherited from Object:
public String toString() {
return "Point: " + x + "," + y;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -