Name: Anonymous 2007-02-12 5:54
Hello, I am currently working on a Java program and I have come across a bit of a problem. I am using an interface and two classes to make a list of objects. The program currently includes an interface List, a class ConsList which implements List and contains an object "first" and a ConsList "rest", as well as a class EndList implementing List which contains an object "last" and is used to terminate the list. An example of use would be:
List l = new ConsList(foo,new ConsList(foo2, new EndList(end)));
All classes implementing List need to have a shiftRight(object o) method, which puts "o" at the beginning of the list, and removes the last object from the list. I have been trying to write this for a while now, but as I am not exceptional at Java the proper method definition continues to elude me. I would greatly appreciate any help. Thank you in advance.
List l = new ConsList(foo,new ConsList(foo2, new EndList(end)));
All classes implementing List need to have a shiftRight(object o) method, which puts "o" at the beginning of the list, and removes the last object from the list. I have been trying to write this for a while now, but as I am not exceptional at Java the proper method definition continues to elude me. I would greatly appreciate any help. Thank you in advance.