Hello- I cant seem to figure out why I am getting the following error:
cannot find symbol : class CD
location: class Inventory5
CD cd = (CD)supplies[currentIndex];
^
I'm getting this on several lines, and something tells me it is a silly error, but I can't find it. Here is the part of the code where I get the errors:
cannot find symbol : class CD
location: class Inventory5
CD cd = (CD)supplies[currentIndex];
^
I'm getting this on several lines, and something tells me it is a silly error, but I can't find it. Here is the part of the code where I get the errors:
Code:
CD cd = (CD)supplies[currentIndex];
int confirm = JOptionPane.showConfirmDialog(this, "Are you sure you want to delete this item? "+cd.getItemNumber());
if(confirm == JOptionPane.YES_OPTION)
{
removeItemAt(currentIndex);
displayFirst();
}
}
}
}
private void modify()
{
CD cd = (CD)supplies[currentIndex];
panel = new JPanel();
JPanel add = new JPanel();
add.setLayout(new GridLayout(8, 3));
JButton update = makeButton("Update");
JLabel number = new JLabel("Number :");
JLabel name = new JLabel("Name :");
JLabel rating = new JLabel("Rating :");
JLabel quantity = new JLabel("Quantity :");
JLabel price = new JLabel("Price :");
add.add(number);
numberField.setText(""+cd.getItemNumber()); numberField.setEditable(false); add.add(numberField);
add.add(name);
nameField.setText(cd.getItemName()); add.add(nameField);
titleField.setText(cd.getTitle()); titleField.setEditable(false);
add.add(title); add.add(titleField);
add.add(quantity);
quantityField.setText(""+cd.getStockQuantity());
add.add(quantityField);
add.add(price);
add.add(priceField); priceField.setText(""+cd.getItemPrice());
panel.add(add);
JPanel forAddIt = new JPanel();
forAddIt.add(update);
panel.add(forAddIt);
displayHolder.remove(display);
displayHolder.add(panel);
//display = panel;
this.setVisible(true);
}
private void addItemToArray()
{
Product p = new CD(nameField.getText(), supplies.length + 1, Long.parseLong(quantityField.getText()),
Double.parseDouble(priceField.getText()), titleField.getText());
//Extend array by one
Product[] ps = new Product[supplies.length + 1];
for(int i = 0; i < ps.length-1; i++)
{
ps[i] = supplies[i];
}
ps[supplies.length] = p;
supplies = ps;
displayHolder.remove(panel);
displayHolder.add(display);
displayLast();
this.setVisible(false);
this.setVisible(true);
}
//Utility method
private void displayItemAt(int index)
{
CD product = (CDTitle)supplies[index];
itemName.setText("Item Name: "+ product.getItemName());
itemNumber.setText("Item Number: "+ product.getItemNumber());
rating.setText("Rating: "+ product.getRating());
quantity.setText("Quantity In Stock: "+ product.getStockQuantity());
price.setText("Item Price: "+ product.getItemPrice());
totalValue.setText("Total: " + product.calculateInventoryValue());
fee.setText("Fee :"+product.calculateRestockFee());
locked = false;
this.repaint();
this.setVisible(true);
}
Comment