Skip to content
Snippets Groups Projects
Commit a0ae6ae9 authored by Ray Liu's avatar Ray Liu
Browse files

Finished helper function and also removed year, month, day from Recrod.java

parent b02f24ed
No related branches found
No related tags found
No related merge requests found
......@@ -9,9 +9,7 @@ public class Record implements Comparable<Record> {
private final float latitude;
private final float longitude;
private final int year;
private final int month;
private final int day;
private final Date recDate;
......@@ -27,9 +25,7 @@ public class Record implements Comparable<Record> {
this.latitude = latitude;
this.longitude = longitude;
this.year = year;
this.month = month;
this.day = day;
this.recDate = new Date(year,month,day);
}
......@@ -83,34 +79,6 @@ public class Record implements Comparable<Record> {
return longitude;
}
/**
* Gets year of the record
*
* @return The year of the record
*/
public int getYear() {
return year;
}
/**
* Gets month of the record
*
* @return The month of the record
*/
public int getMonth() {
return month;
}
/**
* Gets day of the record
*
* @return The day of the record
*/
public int getDay() {
return day;
}
/**
* Gets date of the record
*
......
package sort;
import data.Record;
import data.Date;
public class RangeHelper {
public static GeneralRange<Record> taxonID(Bound boundtype) {
if (boundtype == Bound.ANY) {
......@@ -17,11 +17,11 @@ public class RangeHelper {
return range;
}
else if (boundtype == Bound.UPPER) {
GeneralRange<Record> range = p -> p.getTaxonId() > bound ? 0 : 1;
GeneralRange<Record> range = p -> p.getTaxonId() > bound ? 0 : -1;
return range;
}
else if (boundtype == Bound.EQUALS) {
GeneralRange<Record> range = p -> p.getTaxonId() == bound ? 0 : 1;
GeneralRange<Record> range = p -> p.getTaxonId() - bound ;
return range;
}
else return null;
......@@ -43,23 +43,23 @@ public class RangeHelper {
else return null;
}
public static GeneralRange<Record> longitude(Bound boundtype, int bound) {
public static GeneralRange<Record> longitude(Bound boundtype, float bound) {
if (boundtype == Bound.LOWER) {
GeneralRange<Record> range = p -> p.getLongitude() < bound ? 0 : 1;
return range;
}
else if (boundtype == Bound.UPPER) {
GeneralRange<Record> range = p -> p.getLongitude() > bound ? 0 : 1;
GeneralRange<Record> range = p -> p.getLongitude() > bound ? 0 : -1;
return range;
}
else if (boundtype == Bound.EQUALS) {
GeneralRange<Record> range = p -> p.getLongitude() == bound ? 0 : 1;
GeneralRange<Record> range = p -> Float.compare(p.getLongitude(), bound) ;
return range;
}
else return null;
}
public static GeneralRange<Record> longitude(Bound boundtype, int leftbound, int rightbound) {
public static GeneralRange<Record> longitude(Bound boundtype, float leftbound, float rightbound) {
if (boundtype == Bound.LOWHIGH) {
GeneralRange<Record> range = p -> p.getLongitude() < leftbound ? -1 : (p.getLongitude() > rightbound ? 1 : 0);
return range;
......@@ -75,17 +75,17 @@ public class RangeHelper {
else return null;
}
public static GeneralRange<Record> latitude(Bound boundtype, int bound) {
public static GeneralRange<Record> latitude(Bound boundtype, float bound) {
if (boundtype == Bound.LOWER) {
GeneralRange<Record> range = p -> p.getLatitude() < bound ? 0 : 1;
return range;
}
else if (boundtype == Bound.UPPER) {
GeneralRange<Record> range = p -> p.getLatitude() > bound ? 0 : 1;
GeneralRange<Record> range = p -> p.getLatitude() > bound ? 0 : -1;
return range;
}
else if (boundtype == Bound.EQUALS) {
GeneralRange<Record> range = p -> p.getLatitude() == bound ? 0 : 1;
GeneralRange<Record> range = p -> Float.compare(p.getLatitude(), bound);
return range;
}
else return null;
......@@ -98,4 +98,36 @@ public class RangeHelper {
}
else return null;
}
public static GeneralRange<Record> date(Bound boundtype) {
if (boundtype == Bound.ANY) {
GeneralRange<Record> range = p -> 0;
return range;
}
else return null;
}
public static GeneralRange<Record> date(Bound boundtype, Date bound) {
if (boundtype == Bound.LOWER) {
GeneralRange<Record> range = p -> p.getDate().compareTo(bound) == -1 ? 0 : 1;
return range;
}
else if (boundtype == Bound.UPPER) {
GeneralRange<Record> range = p -> p.getDate().compareTo(bound) == 1 ? 0 : -1;
return range;
}
else if (boundtype == Bound.EQUALS) {
GeneralRange<Record> range = p -> p.getDate().compareTo(bound) ;
return range;
}
else return null;
}
public static GeneralRange<Record> date(Bound boundtype, Date leftbound, Date rightbound) {
if (boundtype == Bound.LOWHIGH) {
GeneralRange<Record> range = p -> p.getDate().compareTo(leftbound) == -1 ? -1 : (p.getDate().compareTo(rightbound) == 1 ? 1 : 0);
return range;
}
else return null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment