Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit da5933e

Browse files
authored
Add files via upload
1 parent a88e159 commit da5933e

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

Diff for: cowjump.java

+18-10
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public static void main(String[] args) throws IOException{
6262
points.add(b);
6363
segements.add(new LineSegement(a, b));
6464
}
65+
f.close();
6566
points.sort(null);
6667
// Algorthim
6768
int size = points.size();
@@ -70,8 +71,8 @@ public static void main(String[] args) throws IOException{
7071
//System.out.println(points.get(i));
7172
}
7273
for(int i =0 ; i < N; i ++) {
73-
//System.out.println(Arrays.toString(lookup[i]));
74-
//System.out.println(segements.get(i));
74+
System.out.println(Arrays.toString(lookup[i]));
75+
System.out.println(segements.get(i));
7576
}
7677

7778
int currentY = -1;
@@ -90,7 +91,7 @@ public static void main(String[] args) throws IOException{
9091
}else {
9192
*/
9293
int state = num(p.index,p,lookup);
93-
//System.out.println("Endpoint "+ state + " "+p);
94+
System.out.println("Endpoint "+ state + " "+p);
9495
if(state == 0) {
9596
pz.add(p.index);
9697
}else if(state == 1) {
@@ -105,8 +106,8 @@ public static void main(String[] args) throws IOException{
105106
//if(j == k){
106107
// continue;
107108
//}
108-
if(Point.intersection(segements.get(j),segements.get(k))) {
109-
//System.out.println("Intersectsion at "+segements.get(j)+" -|||- "+segements.get(k));
109+
if(Point.intersection(segements.get(pz.get(j)),segements.get(pz.get(k)))) {
110+
System.out.println("Intersectsion at "+segements.get(j)+" -|||- "+segements.get(k));
110111
tbl[i] ++;
111112
tbl[j] ++;
112113
if(tbl[i] > max) {
@@ -123,7 +124,7 @@ public static void main(String[] args) throws IOException{
123124
//}
124125
}
125126
// File Writting
126-
//System.out.println(max + " " + maxi + " " + Arrays.toString(tbl));
127+
System.out.println(max + " " + maxi + " " + Arrays.toString(tbl));
127128
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("cowjump.out")));
128129
pw.println(max + 1);
129130
pw.close();
@@ -176,7 +177,7 @@ static boolean intersection(LineSegement a,LineSegement b) {
176177
return intersection(a.a, a.b, b.a, b.b);
177178
}
178179
public String toString() {
179-
return "| ("+this.x + ","+ this.y + ") INDEX "+this.index + " |";
180+
return "("+this.x + ","+ this.y + ","+this.index+")";
180181
}
181182
boolean eq(Point q) {
182183
if(q.x == this.x && q.y == this.y) {
@@ -186,7 +187,14 @@ boolean eq(Point q) {
186187
}
187188
@Override
188189
public int compareTo(Point arg0) {
189-
return Double.compare(this.x, arg0.x);
190+
if(arg0.x == this.x) {
191+
return Double.compare(this.y, this.y);
192+
}else if(this.x < arg0.x) {
193+
return -1;
194+
}else {
195+
return 1;
196+
}
197+
//return Double.compare(this.x, arg0.x);
190198
//return 0;
191199
}
192200
}
@@ -197,8 +205,8 @@ public LineSegement(Point a,Point b) {
197205
this.a = b;
198206
this.b = a;
199207
}else {
200-
this.a = a;
201-
this.b = b;
208+
this.a = a;
209+
this.b = b;
202210
}
203211

204212
}

0 commit comments

Comments
 (0)