I'm guessing this is a class assignment and your instructor wants you to modify it. The program has been done for you. All you have to do is retrieve the values associated with the items that are stored in the items array which are already given in the code. First things first, forget about the output that is being done in GetTax.compute. It has nothing to do with what your instructor wants you to do. Focus only on Class1 and Class3.
The items array is holding 3 items. Each item is an object that stores the barcode, name and price. These values have been hardcoded into the main method of class PosCalProgram.
When the program runs, the main method is the first to be initialized(made active). In this process, 3 item objects are created (initialized). I will walk you through the first initialization of the first item.
items[0]=new item("521412", "Shoes", 200)
1. During initialization of the first item (we are in class1), the item class(result will be an object on the heap after its initialization) is passed 3 parameters. The fist parameter is a String object, the second a String object and the third is a primitive double value (control temporarily passes to class3).
Since an item is being invoked by the main method, the item constructor begins to process all that is within it.
Its variables barcode is assigned the String object "521412", name is assigned the String object "Shoes", and price is assigned the primitive double value 200 (control passes back to class1 and the next two items are go through the same initialization process).
Control is now back in class1. The method printArray(items); is invoked (called to be used, so control is given to this method which is passed an object reference to the items array (remember, this array holds a reference to the 3 item objects stored in memory. The reference is a bit pattern pointing to the item objects and not the actual objects themselves). It is within this method where you would print the values of each item object to the output screen. It is here where your instructor wants you to learn something valueable, so I won't give you the full details. Try to figure this part out and then report back with your findings.