-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPA2.java
76 lines (46 loc) · 1.6 KB
/
PA2.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// The University of Newcastle
// School of Electrical Engineering and Computer Science
// SENG2200 Programming Languages & Paradigms
// Semester 1, 2018
// Programming Assignment 2
// Due Sunday, 06 May 2018
// Author: Binbin Wang
// Modified by: Binbin Wang
// Student No: 3214157
import java.io.*;
import java.util.*;
public class PA2 {
public static void main(String[] args) {
System.out.println("==========START==========");
System.out.println("=========GET DATA FILE============");
String fileName=args[0];
LinkedList<Polygon> myPolygons = new LinkedList<>();
try{
Scanner inputStream = new Scanner (new File (fileName));//get the database name
String dataStr=null;
int i=0;
//get the all data by each line
while (inputStream.hasNextLine ())
{i++;
dataStr = inputStream.nextLine ();
//check the empty line
System.out.println(i+"=========test get point data============");
Polygon newPolygon =new Polygon();
//String dataStr="P 6 2 2 4 6 11 8 7 4 9 1 5 1";
newPolygon.setPoints(dataStr);
myPolygons.append(newPolygon);
}
inputStream.close ();
}catch(Exception erro){
System.out.println(erro.toString());
}
SortedList sortedList = new SortedList();
System.out.println("========ouput datas=============");
System.out.println(myPolygons.toString());
System.out.println("=====================");
System.out.println("=====================");
System.out.println("=====================");
System.out.println("=====================");
System.out.println("=====================");
}
}