forked from sctracy/algs-collinear
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPointPlotter.java
35 lines (31 loc) · 1.12 KB
/
PointPlotter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*************************************************************************
* Compilation: javac PointPlotter.java
* Execution: java PointPlotter input.txt
* Dependencies: Point.java, In.java, StdDraw.java
*
* Takes the name of a file as a command-line argument.
* Reads in an integer N followed by N pairs of points (x, y)
* with coordinates between 0 and 32,767, and plots them using
* standard drawing.
*
*************************************************************************/
public class PointPlotter {
public static void main(String[] args) {
// rescale coordinates and turn on animation mode
StdDraw.setXscale(0, 32768);
StdDraw.setYscale(0, 32768);
StdDraw.show(0);
// read in the input
String filename = args[0];
In in = new In(filename);
int N = in.readInt();
for (int i = 0; i < N; i++) {
int x = in.readInt();
int y = in.readInt();
Point p = new Point(x, y);
p.draw();
}
// display to screen all at once
StdDraw.show(0);
}
}