0

I can't seem to resolve these errors. I have had people compile these codes on their computers with no problem, but I keep getting errors...can anyone help????

Here are the errors:
cannot find symbol method setItemNumber(java.lang.String)
cannot find symbol method setProductName(java.lang.String)
cannot find symbol method setNumOfUnitsInStock(int)
cannot find symbol method getItemNumber()
cannot find symbol method getProductName()
cannot find symbol method getNumOfUnitsInStock()

Here is the Product Code:

public class Product
{
public String movieName; //movie name
private double price; //movie price
private int units; //number in inventory
private String prodID; //product ID number
public Product() { }
public void setMovieName(String _movieName)
{
movieName = _movieName;
}
public void setPrice(double _price)
{
price = _price;
}
public void setUnits(int _units)
{
units = _units;
}
public void setProductID(String _prodID)
{
prodID = _prodID;
}
public String getMovieName()
{
return movieName;
}
public double getPrice()
{
return price;
}
public int getUnits()
{
return units;
}
public String getProductID()
{
return prodID;
}
public double getTotalValue()
{
return units * price;
}
}

Here is the Inventory Code:

import java.util.Arrays;
public class Inventory
{
static public final int MAX_NUM_OF_PRODUCTS = 10;
private Product products[] = new Product[MAX_NUM_OF_PRODUCTS];
private int numOfProducts;
public Inventory()
{
}
public double getInventoryValue()
{
double inventoryValue = 0;
for (int i = 0; i < products.length; i++)
{
Product product = products[i];
if (product != null)
{
inventoryValue += product.getTotalValue();
}
}
return inventoryValue;
}
public Product[] getSortedInventoryList()
{
Arrays.sort(products, 0, numOfProducts) ;
return products;
}
public void addProduct(int index,Product product)
{
products[index] = product;
numOfProducts++;
}
public int getNumOfProducts()
{
return numOfProducts;
}
}

Here is the TestDriver:

import java.util.Scanner;
import java.text.NumberFormat;
public class TestDriver
{ 
 private Inventory inventory;  
 
 public TestDriver() 
 {  
  inventory = new Inventory(); 
 }  
 
 public void acceptInput() 
 {  
  Scanner keyInput = new Scanner(System.in);  
  int counter = 0;  
  while (true)  
  {   
   if (counter > Inventory.MAX_NUM_OF_PRODUCTS)   
   {    
    break;   
   }      
 
   System.out.print("Enter product Name (enter stop to quit):");   
   String productName = keyInput.next();   
   if (productName.equalsIgnoreCase("STOP"))   
   {    
    return;   
   }     
   System.out.print("Enter item number:");   
   String itemNumber = keyInput.next();     
   System.out.print("Enter number of units in stock:");   
   int numUnitsInStock;   
   while ((numUnitsInStock = keyInput.nextInt()) <= 0)   
   {    
    System.out.print("Please enter a valid number:");   
   }   
 
   System.out.print("Enter price:");   
   double price;   
   while ((price = keyInput.nextDouble()) <= 0)   
   {    
    System.out.print("Please enter a valid number:");   
   }      
   Product  product = new Product();   
   product.setItemNumber(itemNumber);   
   product.setProductName(productName);   
   product.setNumOfUnitsInStock(numUnitsInStock);   
   product.setPrice(price);      
   inventory.addProduct(counter, product);   
   counter++;  
  } 
 }  
 
 public void displayOutput() 
 {  
  NumberFormat moneyFormat = NumberFormat.getCurrencyInstance();  
  Product products[] = inventory.getSortedInventoryList();  
  for (int i = 0; i < inventory.getNumOfProducts(); i++)  
  {   
   Product product = products[i];   
   System.out.printf("Item number: %s\n", product.getItemNumber());   
   System.out.printf("Product Name: %s\n", product.getProductName());      
   System.out.printf("Number of units in stock: %d\n", product.getNumOfUnitsInStock());         
   System.out.printf("Price: %s\n", moneyFormat.format(product.getPrice()));            
   System.out.printf("Total value: %s\n", moneyFormat.format(product.getTotalValue()));              
  }  
 
  System.out.printf("Total Inventory value: %s\n", moneyFormat.format(inventory.getInventoryValue())); 
 }  
 
 static public void main(String[] args) 
 {  
  TestDriver driver = new TestDriver();  
  driver.acceptInput();  
  driver.displayOutput(); 
 }
}
2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by thekashyap
0

I just did a Ctrl+F in this thread for following 3 functions:
cannot find symbol method setItemNumber(java.lang.String)
cannot find symbol method setProductName(java.lang.String)
cannot find symbol method setNumOfUnitsInStock(int)

I didn't see their definition..
That should be the problem.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.