Hey guys,
I've come from another thread in hopes that someone can explain whether this is correct or not more simply (to get it through my java newbie brain without being too complicated for a newcomer).
In the code below everything that is commented //add is by me. If you look right below that code at the TODO you'll see my instructions were to fill the menuDescriptions array with the item descriptions. I'm new at this but this program consists of 9 classes, if you need to see the rest of this class or other related classes to know what is going on please let me know.
//method to return an array of descriptions public String[] getMenuDescriptions(){ String menuDescription[] = new String[menuItems.length]; menuDescription[0] += menuItems[0].toString(); // add menuDescription[1] += menuItems[1].toString(); //add menuDescription[2] += menuItems[2].toString(); //add menuDescription[3] += menuItems[3].toString(); //add menuDescription[4] += menuItems[4].toString();//add menuDescription[5] += menuItems[5].toString();//add menuDescription[6] += menuItems[6].toString();//add menuDescription[7] += menuItems[7].toString();//add menuDescription[8] += menuItems[8].toString();//add //TODO //FILL THE ARRAY menuDescription with the descriptions of the menu items //return the menuDescription back to the calling method return menuDescription;
Here is a snippet of the same class with some code mentioned above to give you an idea of where menuItems came from:
public Menu(){ menuItems = new Product[9]; Product book; book = new Product("BK100", "Book", "Java", 12.99); menuItems[0] = book; book = new Product("BK200", "Book", "VB", 16.99); menuItems[1] = book; book = new Product("BK300", "Book", "PHP", 15.99); menuItems[2] = book;
Thanks, hope to make this my java program help forum!