costPerItem, itemQuantity, and productName keep getting the error "cannot find symbol"
package shoppingcart;
import java.text.DecimalFormat;
public class ShoppingCart {
private double totalCost;
private LineItem[] myItems;
private int max = 100;
int numberOfItems;
//Provide a constructor for this class
public ShoppingCart(int size){
max = size;
this.totalCost = 0;
myItems = new LineItem[max];
numberOfItems = 0;
}
//add a method to add a line item object to this class
public void addItem(LineItem newItemObject){
if(numberOfItems < max - 1){ //max - 1 due to the actual index
myItems[numberOfItems++] = newItemObject;
//update the totalcost
totalCost += newItemObject.costPerItem * newItemObject.itemQuantity;
}
}
//a method printing out the carts contents with the total cost of all the items/quantities
public String getDisplayData(){
DecimalFormat myFormat = new DecimalFormat("#.##");
String output = "";
output += "Your shopping cart contains: \n";
output += "\n\t----------------------------------------------";
//Create a loop to display the contents and quantity of the selected cart
for(int x = 0; x < numberOfItems; x++){
//Append the string with a new lineItem
output += "\n\tItem : " + myItems[x].itemQuantity + " x " +
myItems[x].productName + " @ " +
myFormat.format(myItems[x].costPerItem) + " = $" +
myItems[x].costPerItem * myItems[x].itemQuantity;
}
output += "\n\tTotal : $" + myFormat.format(totalCost);
output += "\n\t----------------------------------------------";
return output;
}
public double getTotalCost(){
return totalCost;
}
}