trypolyline.java
来自「Beginning Java 2, SDK 1.4 Edition Exerci」· Java 代码 · 共 28 行
JAVA
28 行
// Chapter 6 Exercise 4
public class TryPolyLine {
public static void main(String[] args) {
// Create an array of coordinate pairs:
double[][] coords = { {1., 1.}, {1., 2.}, { 2., 3.},
{-3., 5.}, {-5., 1.}, {0., 0.} };
// Create a polyline from the coordinates and display it:
PolyLine polygon = new PolyLine(coords);
polygon.show();
// Add a point and display the polyline again:
polygon.addPoint(10., 10.);
polygon.show();
// Create Point objects from the coordinate array:
Point[] points = new Point[coords.length];
for(int i = 0; i < points.length; i++)
points[i] = new Point(coords[i][0],coords[i][1]);
// Use the points to create a new polyline and display it:
PolyLine newPoly = new PolyLine(points);
newPoly.show();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?