Ok after changing in GreetingCard, i made these changes in ECardPrinter as follows:
for(GreetingCard gc : cards){
System.out.println(gc.formatMessage()+"Date :"+gc.arrivalDate);
}
...
Type: Posts; User: haliza hadi
Ok after changing in GreetingCard, i made these changes in ECardPrinter as follows:
for(GreetingCard gc : cards){
System.out.println(gc.formatMessage()+"Date :"+gc.arrivalDate);
}
...
What if i change my compareTo as below...pls help
public int compareTo(GreetingCard other){
if(arrivalDate.before(other.arrivalDate)){
return -1;
}
else{
...
wait i forgot to attach the abstract parent class and the subsequent child class
import java.util.Date;
public abstract class GreetingCard implements Comparable<GreetingCard> {
public...
There are no error messages...however when i implement the Collections.sort(cards) and then do a println, the output are not sorted by date...below is my code
import GreetingCard.*;
import...
And in addition to the sorting problem...how do i use attributes from another package???I have tried importing the package but it won't work...pls help :(
Ok ignore my questions..its ask by my friends huhu... btw i'm using Collections.sort and my sort does not do the sorting...
Will there be lots of changes if i declare my parent class GreetingCard to private? And what does private class do to the other class in the same package?
What is the function of the interface Comparable<GreetingCard>?
Yes i did change the spelling for compareTo
import java.util.Date;
public abstract class GreetingCard implements Comparable {
String message;
Date arrivalDate;
...
I try to work out the error in my child class but to no avail...what does this error mean??
BirthdayCard is not abstract and does not override abstract method compareTo(Object) in Comparable
----
ok..i've found the spelling for method "compareTo"
which spelling do i need to correct and from which class??
import java.util.Date;
public abstract class GreetingCard implements Comparable {
String message;
Date arrivalDate;
GreetingCard(String message, Date arrivalDate){
...
[/code]
import java.util.Date;
public abstract class GreetingCard implements Comparable {
String message;
Date arrivalDate;
GreetingCard(String message, Date arrivalDate){
...
How do i post in code tags?
ok so i know i have to override the abstract method compareTo, but how should i code it in my other extends class?I am a beginner for object oriented programming so pls guide me huhu
This is parent class
import java.util.Date;
public abstract class GreetingCard implements Comparable {
String message;
Date arrivalDate;
GreetingCard(String message, Date...
I'm still getting this same error messages. Sorry this is my first try doing object oriented programming #:-s
I did re-check my spelling and caps everything seems to be fine to me. Cud u pls check...
ok got it thanks...the compiler is unforgiving...:))
--- Update ---
ok now i have this error :BirthdayCard is not abstract and does not override abstract method compareTo(object) in...
so if i change my code in parent class to just greetingCard(String m, Date d){} i'm getting error now in my parent class. SO how should i write the code in?
Hi i'm trying to call super constructor but found the error :call to super must be first statement in constructor.
This is my code in parent class (NO ERRORS)
import java.util.Date;
public...