public static void main(String args) throws FileNotFoundException
//Array array = new Array();
System.out.println("Please Enter the Item you Would Like to Purchase");
//Itemitems = new Item;
Item itm = new Item("d", 2.2, 3);
System.out.println("You are lucky, we found your Item.");
System.out.println("Did not find your item");
For now my code only finds whether the item is available or not. But what i want to do is to print out the name of the item found along with its quantity and cost.
Please help me with this. I have been struggling with it for a long time
Why is your ItemFound method creating several items. A method should do exactly what it's name suggests it should do, nothing more and nothing less. By all means have a method that initialises your data but call it something that says that's what it is doing.
Also why are you passing values into the constructor of each item and then immediately changing the values with setXXX, why not pass the correct values into the constructor to start with. And why are you calling getXXX on all your items and ignoring the returned values?
If you want to print out the details of the item then you need a method that takes the item name as a parameter and returns the item with that name. Once you have the item you can then use the getXXX methods to extract the details from it. Remember to handle the case where someone asks for an item you don't have. In such a case your method can either return null or possibly throw an exception, which will need handling in the calling code.