Errors I can't resolve!!!

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jun 2007
Posts: 5
Reputation: 4zlimit is an unknown quantity at this point 
Solved Threads: 0
4zlimit 4zlimit is offline Offline
Newbie Poster

Errors I can't resolve!!!

 
0
  #1
Jun 22nd, 2007
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:
  1. public class Product
  2. {
  3. public String movieName; //movie name
  4. private double price; //movie price
  5. private int units; //number in inventory
  6. private String prodID; //product ID number
  7. public Product() { }
  8. public void setMovieName(String _movieName)
  9. {
  10. movieName = _movieName;
  11. }
  12. public void setPrice(double _price)
  13. {
  14. price = _price;
  15. }
  16. public void setUnits(int _units)
  17. {
  18. units = _units;
  19. }
  20. public void setProductID(String _prodID)
  21. {
  22. prodID = _prodID;
  23. }
  24. public String getMovieName()
  25. {
  26. return movieName;
  27. }
  28. public double getPrice()
  29. {
  30. return price;
  31. }
  32. public int getUnits()
  33. {
  34. return units;
  35. }
  36. public String getProductID()
  37. {
  38. return prodID;
  39. }
  40. public double getTotalValue()
  41. {
  42. return units * price;
  43. }
  44. }


Here is the Inventory Code:

  1. import java.util.Arrays;
  2. public class Inventory
  3. {
  4. static public final int MAX_NUM_OF_PRODUCTS = 10;
  5. private Product products[] = new Product[MAX_NUM_OF_PRODUCTS];
  6. private int numOfProducts;
  7. public Inventory()
  8. {
  9. }
  10. public double getInventoryValue()
  11. {
  12. double inventoryValue = 0;
  13. for (int i = 0; i < products.length; i++)
  14. {
  15. Product product = products[i];
  16. if (product != null)
  17. {
  18. inventoryValue += product.getTotalValue();
  19. }
  20. }
  21. return inventoryValue;
  22. }
  23. public Product[] getSortedInventoryList()
  24. {
  25. Arrays.sort(products, 0, numOfProducts) ;
  26. return products;
  27. }
  28. public void addProduct(int index,Product product)
  29. {
  30. products[index] = product;
  31. numOfProducts++;
  32. }
  33. public int getNumOfProducts()
  34. {
  35. return numOfProducts;
  36. }
  37. }



Here is the TestDriver:

  1. import java.util.Scanner;
  2. import java.text.NumberFormat;
  3. public class TestDriver
  4. {
  5. private Inventory inventory;
  6.  
  7. public TestDriver()
  8. {
  9. inventory = new Inventory();
  10. }
  11.  
  12. public void acceptInput()
  13. {
  14. Scanner keyInput = new Scanner(System.in);
  15. int counter = 0;
  16. while (true)
  17. {
  18. if (counter > Inventory.MAX_NUM_OF_PRODUCTS)
  19. {
  20. break;
  21. }
  22.  
  23. System.out.print("Enter product Name (enter stop to quit):");
  24. String productName = keyInput.next();
  25. if (productName.equalsIgnoreCase("STOP"))
  26. {
  27. return;
  28. }
  29. System.out.print("Enter item number:");
  30. String itemNumber = keyInput.next();
  31. System.out.print("Enter number of units in stock:");
  32. int numUnitsInStock;
  33. while ((numUnitsInStock = keyInput.nextInt()) <= 0)
  34. {
  35. System.out.print("Please enter a valid number:");
  36. }
  37.  
  38. System.out.print("Enter price:");
  39. double price;
  40. while ((price = keyInput.nextDouble()) <= 0)
  41. {
  42. System.out.print("Please enter a valid number:");
  43. }
  44. Product product = new Product();
  45. product.setItemNumber(itemNumber);
  46. product.setProductName(productName);
  47. product.setNumOfUnitsInStock(numUnitsInStock);
  48. product.setPrice(price);
  49. inventory.addProduct(counter, product);
  50. counter++;
  51. }
  52. }
  53.  
  54. public void displayOutput()
  55. {
  56. NumberFormat moneyFormat = NumberFormat.getCurrencyInstance();
  57. Product products[] = inventory.getSortedInventoryList();
  58. for (int i = 0; i < inventory.getNumOfProducts(); i++)
  59. {
  60. Product product = products[i];
  61. System.out.printf("Item number: %s\n", product.getItemNumber());
  62. System.out.printf("Product Name: %s\n", product.getProductName());
  63. System.out.printf("Number of units in stock: %d\n", product.getNumOfUnitsInStock());
  64. System.out.printf("Price: %s\n", moneyFormat.format(product.getPrice()));
  65. System.out.printf("Total value: %s\n", moneyFormat.format(product.getTotalValue()));
  66. }
  67.  
  68. System.out.printf("Total Inventory value: %s\n", moneyFormat.format(inventory.getInventoryValue()));
  69. }
  70.  
  71. static public void main(String[] args)
  72. {
  73. TestDriver driver = new TestDriver();
  74. driver.acceptInput();
  75. driver.displayOutput();
  76. }
  77. }
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: Errors I can't resolve!!!

 
0
  #2
Jun 22nd, 2007
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.
Are you Agile.. ?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC