?? trypackage.java
字號:
import Geometry.*; // Import the Point and Line classes
public class TryPackage
{
public static void main(String[] args)
{
double[][] coords = { {1.0, 0.0}, {6.0, 0.0}, {6.0, 10.0},
{10.0,10.0}, {10.0, -14.0}, {8.0, -14.0}};
// Create an array of points and fill it with Point objects
Point[] points = new Point[coords.length];
for(int i = 0; i < coords.length; i++)
points[i] = new Point(coords[i][0],coords[i][1]);
// Create an array of lines and fill it using Point pairs
Line[] lines = new Line[points.length - 1];
double totalLength = 0.0; // Store total line length here
for(int i = 0; i < points.length - 1; i++)
{
lines[i] = new Line(points[i], points[i+1]); // Create a Line
totalLength += lines[i].length(); // Add its length
System.out.println("\nLine "+(i+1)+' ' +lines[i] +
" Length is " + lines[i].length());
}
// Output the total length
System.out.println("/n/nTotal line length = " + totalLength);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -