aspose file tools*
The moose likes Java in General and the fly likes interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "interface" Watch "interface" New topic
Author

interface

yom Kipp
Greenhorn

Joined: Sep 30, 2001
Posts: 2
Hi!
How do I write the method:
public Element head(){}
(returns the first element of the list. This element becomes the actual element.If the list is empty isEmpty ==true then head() returns the null object.)
The code is:
import java.*;
import java.lang.*;
class RentalCarStock implements List{
private static Car[] cars;
private int pos = -1,top= -1;
public RentalCarStock(){
cars = new Car[20];
}

public Element head(){}
}

public interface Element {
public boolean equals(Element toCompareWith);
public boolean lessOrEqual(Element toCompareWith);
}

public interface List {
public Element head();
}
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
You'd better finish your assignment by yourself.
yom Kipp
Greenhorn

Joined: Sep 30, 2001
Posts: 2
Thank you Roseanne
I would not ask if I know how to do this.
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
In the old days, students did linked list in Pascal/C, it is much harder to do in those languages. In Java, it is much easier. Give you a hint, go to JDK util package, the linked list is already implemented there, not exactly as your teacher wants, but it would be a pretty good teacher for you. It is not a good idea to throw your teachers assignment and code stems here, and wish Java professionals doing it for you.
Roseanne
 
Consider Paul's rocket mass heater.
 
subject: interface