![]() |
ADT - basic list data type
Calling on All Programmers;
I have a challenging (for me) question that I really need some help to get going in the right direction. I need to code a NewList (ADT) that will implement a separate file shown below: -------------------------------------------- interface SmallList <ItemType> //Small list { public static final int MAX_LENGTH=5; public boolean insertItem (ItemType newItem); public boolean delItem(); public boolean newPos(); public ItemType getItem(); } // End of SmallList -------------------------------------------- What I have at this point is a blank page quite frankly. I need some help to implement the interface shown above. Any help, comments, direction, etc. would be much appreciated. To start: public class NewList <ItemType> implements SmallList <ItemType> { } Thanks |
When a class implements an interface, the programmer must define all the method that are in that interface. Here's a small example of a class that implements an interface.
:
import java.util.Stack;For your ADT, you just have to define all those methods in your class. :
public class NewList<ItemType> implements SmallList<ItemType> |
Thanks for your help. Here is a quick description of the above:
:
public class NewList<ItemType> implements SmallList<ItemType> |
perhaps a "heap" data structure would fulfill your needs? if java doesn't have one, then oh well...
|
Dude, if you can't convert your pseudocode into Java statements then I suggest you read up on Java. All you have to do is create private list object within your NewList class and just remove according to the directions given.
Also, the p value never changes. Is p the first index of your list? Why do you keep track of the position when all you do is remove an object from the front of the list? This data structure of yours does not make sense and has no point because all you are doing in reinventing the wheel. |
| All times are GMT -5. The time now is 12:36 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC