| 94 |
Kevin |
1 |
/*
|
|
|
2 |
* CS 3114 Project 2
|
|
|
3 |
* Author: Kevin Lee
|
|
|
4 |
* Compiler: Eclipse 3.7.0
|
|
|
5 |
* Operating System: Windows 7 x64
|
|
|
6 |
* Date Completed: 10/7/2011
|
|
|
7 |
*
|
|
|
8 |
* The following program is an implementation of two different
|
|
|
9 |
* trees that allows for efficient storing of records with
|
|
|
10 |
* coordinates. A binary search tree is used to allow for
|
|
|
11 |
* efficient search by name, while a point region quad tree is
|
|
|
12 |
* used to allow for efficient search by coordinates. The
|
|
|
13 |
* program parses an input file for commands, and outputs the
|
|
|
14 |
* results to standard out.
|
|
|
15 |
*
|
|
|
16 |
* On my honor:
|
|
|
17 |
*
|
|
|
18 |
* - I have not used source code obtained from another student,
|
|
|
19 |
* or any other unauthorized source, either modified or
|
|
|
20 |
* unmodified.
|
|
|
21 |
*
|
|
|
22 |
* - All source code and documentation used in my program is
|
|
|
23 |
* either my original work, or was derived by me from the
|
|
|
24 |
* source code published in the textbook for this course.
|
|
|
25 |
*
|
|
|
26 |
* - I have not discussed coding details about this project with
|
|
|
27 |
* anyone other than my partner (in the case of a joint
|
|
|
28 |
* submission), instructor, ACM/UPE tutors or the TAs assigned
|
|
|
29 |
* to this course. I understand that I may discuss the concepts
|
|
|
30 |
* of this program with other students, and that another student
|
|
|
31 |
* may help me debug my program so long as neither of us writes
|
|
|
32 |
* anything during the discussion or modifies any computer file
|
|
|
33 |
* during the discussion. I have violated neither the spirit nor
|
|
|
34 |
* letter of this restriction.
|
|
|
35 |
*/
|
|
|
36 |
|
|
|
37 |
import java.io.BufferedReader;
|
|
|
38 |
import java.io.File;
|
|
|
39 |
import java.io.FileNotFoundException;
|
|
|
40 |
import java.io.FileReader;
|
|
|
41 |
import java.io.IOException;
|
|
|
42 |
|
|
|
43 |
public class PRProg {
|
|
|
44 |
|
|
|
45 |
public static void main(String[] args) {
|
|
|
46 |
|
|
|
47 |
String input_commandFile; // Location of file to parse
|
|
|
48 |
|
|
|
49 |
// 3 arguments must be supplied to the program
|
|
|
50 |
if (args.length != 1) {
|
|
|
51 |
System.out.println("1 Arguments must be supplied!");
|
|
|
52 |
return;
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
// Parses passed arguments into member variables
|
|
|
56 |
input_commandFile = args[0];
|
|
|
57 |
|
|
|
58 |
// Check to make sure the command file exists
|
|
|
59 |
File cmdFile = new File(input_commandFile);
|
|
|
60 |
if (!cmdFile.exists()) {
|
|
|
61 |
System.out.printf("Command file not found");
|
|
|
62 |
return;
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
CmdParser GISParser = new CmdParser();
|
|
|
66 |
|
|
|
67 |
// Parse each command with the memory client
|
|
|
68 |
try {
|
|
|
69 |
BufferedReader reader = new BufferedReader(new FileReader(cmdFile));
|
|
|
70 |
String cin;
|
|
|
71 |
while ((cin = reader.readLine()) != null) {
|
|
|
72 |
cin = cin.trim();
|
|
|
73 |
if (cin.length() != 0) {
|
|
|
74 |
// Send string to command parser
|
|
|
75 |
GISParser.Parse(cin);
|
|
|
76 |
}
|
|
|
77 |
}
|
|
|
78 |
} catch (FileNotFoundException e) {
|
|
|
79 |
System.out.printf("Command file not found");
|
|
|
80 |
return;
|
|
|
81 |
} catch (IOException e) {
|
|
|
82 |
System.out.printf("Unable to read input file");
|
|
|
83 |
return;
|
|
|
84 |
}
|
|
|
85 |
}
|
|
|
86 |
}
|