diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Date.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Date.java index c29b006..550ce68 100644 --- a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Date.java +++ b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Date.java @@ -74,22 +74,52 @@ public class Date implements Comparable{ return this.mHour +":"+ this.mMinute +":"+ this.mSecond +" "+ this.mMonth +"-"+ this.mDay +"-"+ this.mYear; } - /** - * @return the total value of month + day + year + hour + minute + second - * @author ricky barrette - */ - public long total(){ - return this.mDay + this.mHour + this.mMinute + this.mMonth + this.mSecond + this.mYear; - } @Override public int compareTo(Date date) { - long thisTotal = this.total(); - long thatTotal = date.total(); - if(thisTotal < thatTotal) - return -1; //before - if(thisTotal > thatTotal) - return 1; //after - return 0;//equal + if(this.mYear != date.getYear()) + return this.mYear > date.getYear() ? 1 : -1; + else + if(this.mMonth != date.getMonth()) + return this.mMonth > date.getMonth() ? 1 : -1; + else + if(this.mDay != date.getDay()) + return this.mDay > date.getDay() ? 1 : -1; + else + if(this.mHour != date.getHour()) + return this.mHour > date.getHour() ? 1 : -1; + else + if(this.mMinute != date.getMinute()) + return this.mMinute > date.getMinute() ? 1 : -1; + else + if(this.mSecond != date.getSecond()) + return this.mSecond > date.getSecond() ? 1 : -1; + else + return 0; + + } + + private int getSecond() { + return this.mSecond; + } + + private int getMinute() { + return this.mMinute; + } + + private int getHour() { + return this.mHour; + } + + private int getDay() { + return this.mDay; + } + + private int getMonth() { + return this.mMonth; + } + + private int getYear() { + return this.mYear; } } \ No newline at end of file diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Order.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Order.java index fd9e5b2..e7799ea 100644 --- a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Order.java +++ b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Order.java @@ -93,8 +93,8 @@ public class Order implements Comparable{ */ @Override public int compareTo(Order o) { - return this.mItemName.compareTo(o.getItemName()); -// return this.mOrderCreationDate.compareTo(o.getOrderCreationDate()); +// return this.mItemName.compareTo(o.getItemName()); + return this.mOrderCreationDate.compareTo(o.getOrderCreationDate()); }