Oh it's there. The symbol is there. I've bee staring at it for an hour. Ugh. It's making me grumpy.
Here's my code. Originally, it had six or seven additional methods, but since they were all giving me the same ugly error, I set them aside for a while.
Code:import java.io.*;
//class to instantiate Item objects
public class Item
{
public Item()
{
long num;
String descrip;
double bCost;
double sPrice;
int amount;
}
public Item(long num, String d, double cost, double price, int cAmount)
{
long itemNum = num;
String descrip = d;
double wCost = cost;
double sPrice = price;
int amount = cAmount;
}
}
//class to hold inventory list
class Inventory
{
//instantiate inventory list
public Inventory()
{
Item[] itemList;
long[] freeNums;
int cnt = 0;
}
public Inventory(int size)
{
Item[] itemList = new Item[size]; //actual Inventory
long[] freeNums = new long[size]; //list of possible numbers for new items
int cnt = 0; //keep track of new items added
//fill freeNums
for(int i = 0; i < size; i++)
freeNums[i] = size + 1; //ie; 101 - 201
}
}
//class to manipulate current inventory
class InvMaintenance
{
final static int MAX = 100; //constant for array length
Inventory c = new Inventory(MAX); //instantiate Inventory object
public static void main(String[] args)
{
InvMaintenance inv = new InvMaintenance();
try
{
//Check for previous save file
//if File Not Found, create new file
//create an OutputStream to write data to a file
File saveFile = new File("inven.txt");
FileOutputStream fos = new FileOutputStream(saveFile);
BufferedOutputStream bos = new BufferedOutputStream(fos);
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(inv.c); //write initial Inventory to file
//Output options
/* Inventory Maintenance
1) Add Item
2) Remove Item
3) Sell Item
4) Receive Item
5) Display Inventory
6) Quit
Please Select NUMBER: */
//switch on options
//call appropriate method
oos.writeObject(inv.c);
oos.close();
}
catch(Exception e) {}
}
//method to traverse entire inventory
public void display()
{
for(int i = 0; i < c.cnt; i++)
{
System.out.println("Item number:" + c.itemList[i].itemNum);
System.out.println("Description:" + c.itemList[i].descrip);
System.out.println("Wholesale cost:" + c.itemList[i].wCost);
System.out.println("Sale price:" + c.itemList[i].sPrice);
System.out.println("Balance on hand:" + c.itemList[i].amount);
}
}
}
And here is my javac error:
I very clearly see that there is a cnt and itemList variable in my Inventory constructor. My Terminal disagrees. But it's been a long night.Code:Item.java:104: cannot find symbol
symbol : variable cnt
location: class Inventory
for(int i = 0; i < c.cnt; i++)
^
Item.java:106: cannot find symbol
symbol : variable itemList
location: class Inventory
System.out.println("Item number:" + c.itemList[i].itemNum);
^
Item.java:107: cannot find symbol
symbol : variable itemList
location: class Inventory
System.out.println("Description:" + c.itemList[i].descrip);
^
Item.java:108: cannot find symbol
symbol : variable itemList
location: class Inventory
System.out.println("Wholesale cost:" + c.itemList[i].wCost);
^
Item.java:109: cannot find symbol
symbol : variable itemList
location: class Inventory
System.out.println("Sale price:" + c.itemList[i].sPrice);
^
Item.java:110: cannot find symbol
symbol : variable itemList
location: class Inventory
System.out.println("Balance on hand:" + c.itemList[i].amount);
^
6 errors
Any help will be incredibly greatly appreciated!

