| | |
Errors I can't resolve!!!
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jun 2007
Posts: 5
Reputation:
Solved Threads: 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:
Here is the Inventory Code:
Here is the TestDriver:
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:
Java Syntax (Toggle Plain Text)
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:
Java Syntax (Toggle Plain Text)
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:
Java Syntax (Toggle Plain Text)
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(); } }
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.
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.. ?
![]() |
Similar Threads
- help needed 3 errors (Java)
- Startup Errors (Windows NT / 2000 / XP)
- 2 errors (Windows NT / 2000 / XP)
- cannot resolve symbol symbol : variable JoptionPane (IT Professionals' Lounge)
- not to sound cliche, but...help me please! (Java)
- "Cannot Resolve Symbol" (Java)
- Page Cannot Be Displayed & javascript:doNetDetect() Errors (Viruses, Spyware and other Nasties)
- Loader.EXE and IEDLL.EXE errors (Web Browsers)
- Two Problems- "Page Cannot Be Displayed" Errors, Z (Windows NT / 2000 / XP)
Other Threads in the Java Forum
- Previous Thread: A few questions regarding video, images and audio
- Next Thread: Tomcat
| Thread Tools | Search this Thread |
911 actionlistener addressbook android api append applet application array arrays automation binary bluetooth character chat class classes client code component consumer csv database desktop draw eclipse error event exception fractal ftp game givemetehcodez graphics gui html ide image input integer j2me japplet java javaarraylist javac javaee javaprojects jmf jni jpanel julia linked linux list loop map method methods mobile netbeans newbie objects online oracle oriented panel print printf problem program programming project projects properties recursion replaydirector reporting researchinmotion robot rotatetext rsa scanner screen se server set size sms sort sql string swing template test threads time tree ubuntu update windows





