If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Array-Based List questions

Hello, I have a question on how array-based lists can be used in a linked list setting. My Java teacher wasn't very clear on how it works so I'm hoping if anyone has explain it to me or direct me to a site where they might be able to I would be most appreciative.

While there was a base class and a derived class i'm digressing. Can anyone either explain how the arrays can be put into the list or direct me to a site where they might start with maybe just one array.

Your declaration of MallList should have parentheses around the names of the arrays, not brackets ... new MallList( names, costs, stores );

I interpret your description as requiring that the MallList class is supposed to take the data in the arrays which are passed as parameters and hold that data in a linked list. Please correct me if that interpretation is wrong.

These three parallel arrays hold the information which, when put together, describes each store of the mall. You refer to the combination of information by the index they share.

If the MallList is supposed to be a linked list, and linked lists hold data and a link, you can create a Node class for your list which holds, as data, one tuple of data indexed by "0", another by "1", and another by "2" from names, costs, stores. It also holds a link to the next Node.

Thank for the help. I did gain a better understanding, unfortunately nodes were not required for this program. I'm hoping if I put up the code I have so far my question would be better understood. I do apologize for the format in advance as well.

//This program will take 3 arrays and make them into a list
//Depending of the type of item, its cost, and its store number
import java.io.*;
public class TestListStudent
{
public static void main(String[] args)
{
String[] names = {"jeans", "shirt", "boots"}; //array for items
double[] costs = {39.99, 24.75, 105.00}; //array for their costs
int[] stores = {16, 29, 3}; //store number that they are at
MallList listOne = new MallList(names,costs,stores);
System.out.println("Is the list full" + listOne.isListFull());//check to see if list is full
listOne.printFowards(); //Print the list
listOne.Insert("socks" + 5.64 + 80); //add socks and its variables to the list
System.out.println("The list in reverse");
listOne.printBackwards(); //Print the list backwards
System.out.println("Is the list full" + listOne.isListFull());//check to see if list is full again
listOne.Insert("necklace" + 12.5 + 3); //add another item
listOne.printFowards(); //print again
System.out.println("Is the list full" + listOne.isListFull());//is list full
}
}

I think you need to put some time into organizing your project. It is time to put pencil to paper and chart out what class structure you are creating, what methods and data in each, and the interaction of classes. What is your program supposed to be doing?

What does your MallList class look like?

In ItemList you seem to declare the object "listOne" (which has all sorts of methods being called in your method main) as an int but then define it as an array of MallList elements.

Why would you assign values to data members of your ItemList class and then have a constructor which takes arguments which redefines these data members?

What is the List() method supposed to be doing in your Item class? (remember the naming pattern - methods are supposed to start with a lower case letter). What is the call to super(List) supposed to do?

I don't understand the relationship of Item and MallItem: can you explain it to me? It does not make sense to me that one derives from the other. You make no apparent use of the inherited data members in the child class.