I don't know what's going on. I should know this by now and have done this dozens of times, but it's not working here.
What I'm trying to do:
I'm trying to pass the itemCode and itemName into commandMethod.(last line)
What I've done:
I've tried different syntax to ensure that I'm not typing it wrong.
public class VendingMachineSimulator {
public void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader("product.txt"));
int i = 0;
String[] newData = new String[25];
Product[] product = new Product[9];
String line;
while ((line = reader.readLine()) != null) {
String itemCodeParse = line.substring(0, 2);
String itemNameParse = line.substring(7, 21);
String itemQuantityParse = line.substring(23, 26);
String itemPriceParse = line.substring(31, 36);
String itemCode = itemCodeParse.trim();
String itemName = itemNameParse.trim();
int itemQuantity = Integer.parseInt(itemQuantityParse.trim());
float itemPrice = Float.parseFloat(itemPriceParse.trim());
product[i] = new Product(itemCode, itemName, itemQuantity, itemPrice);
i++;
}
try {
if (reader != null) reader.close();
} catch (IOException e2) {
System.out.println("Error Closing In File");
}
BufferedReader currReader = new BufferedReader(new FileReader("currency.txt"));
int j = 0;
String[] currData = new String[25];
Currency[] currency = new Currency[5];
String currLine;
while ((currLine = currReader.readLine()) != null) {
String currencyNameParse = currLine.substring(0, 17);
String currencyValueParse = currLine.substring(21, 27);
String currencyQuantityParse = currLine.substring(35, 38);
String currencyName = currencyNameParse.trim();
int currencyQuantity = Integer.parseInt(currencyQuantityParse.trim());
float currencyValue = Float.parseFloat(currencyValueParse.trim());
currency[j] = new Currency(currencyName, currencyQuantity, currencyValue);
j++;
}
try {
if (reader != null) reader.close();
} catch (IOException e2) {
System.out.println("Error Closing In File");
}
displayMenu();
commandMethod(currency, product, id, itemName);