Hi
I'm trying to put together a simple supermarket simulation program in Java (which I don't really know so I'm sort of learning it as I go along) and have hit a problem.
I've got a line that sets up a few shelves when the program first executes which I'm then trying to reference from a method in the same class like so:
I know the code is sloppy (well the structuring is horrid) because it's an alteration job of something that was incomplete.Code:public class MainShop { Shelf a = new Shelf(5); public static void WarehouseOp() { char opt; //Warehouse menu do { System.out.println("\t\t\t\t::Warehouse::\n"); System.out.println("\tEnter a key to run an operation in the warehouse\n"); System.out.println("\tV: View the items in the warehouse"); System.out.println("\tM: Move the items from the warehouse into the shop"); System.out.println("\tQ: Go back into the store"); opt = Input.readChar("\tInput:"); opt = Character.toUpperCase(opt); if (opt == 'V') { Trying to access functions in the Shelf class from here > wanted something like "a.Showproducts();" but doesn't work } } while (opt != 'Q'); }
Any help would be great. Though I can see I'm gonna go wrong with another part pretty soon too![]()




Reply With Quote