📄 line.java
字号:
import dslib.base.PairUos;
/** A line with a length and slope, and also x and y coordinates (inherited from Shape). */
public class Line extends Shape
{
/** length and slope of the line */
protected int length, slope;
/** Create a Line with length newLength and slope newSlope, and positioned at (0,0)
Analysis: Time = O(1) */
public Line(int newLength, int newSlope)
{
length = newLength;
slope = newSlope;
x = 0;
y = 0;
}
/** Set the length and slope to newLength and newSlope
Analysis: Time = O(1) */
public void setDimensions(int newLength, int newSlope)
{
length = newLength;
slope = newSlope;
}
/** String representation of the line
Analysis: Time = O(1) */
public String toString()
{
return "\n" + indent + "Line with length " + length + " and slope " + slope + " degrees"
+ "\n" + super.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -