Join 150,393 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,038 people online right now. Registration is fast and FREE... Join Now!
I cannot seem to figure out the problem. Can anyone help!!!
Here is error:
gui.java:122: cannot find symbol symbol : method getnumItem(int) location: class NameRestock NameRestock aryProd = (NameRestock) inventory.getnumItem(currentProdno); ** The arrow points directly at the period between inventory and getnumItem.
JPanel titlePanel = new JPanel(); titlePanel.setLayout(new FlowLayout(FlowLayout.CENTER)); jl = new JLabel("Inventory Part 4"); titlePanel.add(jl); outerPanel.add(titlePanel);
JPanel numberPanel = new JPanel(); numberPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); jl = new JLabel(" Number: " ); numberPanel.add(jl); jtfprdItem = new JTextField (1); jtfprdItem.setEditable(false); numberPanel.add(jtfprdItem); outerPanel.add(numberPanel);
JPanel number1Panel = new JPanel(); number1Panel.setLayout(new FlowLayout(FlowLayout.LEFT)); jl = new JLabel(" Name: " ); number1Panel.add(jl); jtfprdName = new JTextField (2); jtfprdName.setEditable(false); number1Panel.add(jtfprdName); outerPanel.add(number1Panel);
JPanel number2Panel = new JPanel(); number2Panel.setLayout(new FlowLayout(FlowLayout.LEFT)); jl = new JLabel(" Units: " ); number2Panel.add(jl); jtfprdUnit = new JTextField(3); jtfprdUnit.setEditable(false); number2Panel.add(jtfprdUnit); outerPanel.add(number2Panel);
JPanel number3Panel = new JPanel(); number3Panel.setLayout(new FlowLayout(FlowLayout.LEFT)); jl = new JLabel(" Price: " ); number3Panel.add(jl); jtfprdPrice = new JTextField(4); jtfprdPrice.setEditable(false); number3Panel.add(jtfprdPrice); outerPanel.add(number3Panel);
JPanel number4Panel = new JPanel(); number4Panel.setLayout(new FlowLayout(FlowLayout.LEFT)); jl = new JLabel(" Total: $ " ); number4Panel.add(jl); jtfTotal = new JTextField(5); jtfTotal.setEditable(false); number4Panel.add(jtfTotal); outerPanel.add(number4Panel);
JPanel number5Panel = new JPanel(); number5Panel.setLayout(new FlowLayout(FlowLayout.LEFT)); jl = new JLabel("Restocking Fee: $ " ); number5Panel.add(jl); jtfReStock = new JTextField(6); jtfReStock.setEditable(false); number5Panel.add(jtfReStock); outerPanel.add(number5Panel);
JPanel number6Panel = new JPanel(); number5Panel.setLayout(new FlowLayout(FlowLayout.LEFT)); jl = new JLabel("Restocking Fee: $ " ); number5Panel.add(jl); jtfstrCName = new JTextField(7); jtfstrCName.setEditable(false); number5Panel.add(jtfstrCName); outerPanel.add(number6Panel);
JPanel number7Panel = new JPanel(); number6Panel.setLayout(new FlowLayout(FlowLayout.CENTER)); jl = new JLabel("Total Invenory Value: $" ); number6Panel.add(jl); jtfTotal = new JTextField(8); jtfTotal.setEditable(false); outerPanel.add(number7Panel);
JPanel jpButtons = new JPanel(); JButton jbNext = new JButton("Next"); jbNext.addActionListener(new NextButtonHandler()); jpButtons.add(jbNext); outerPanel.add(jpButtons);
1) Not defined the function getnumItem() 2) You defined the function but have wrong capitalization (could it be getNumItem()?) 3) Or the function is not specified as public or in a scope that can be seen by your GUI class.
So check out that class and see which one it could be. If you still can't find it, post your NameRestock class code.
1) Not defined the function getnumItem() 2) You defined the function but have wrong capitalization (could it be getNumItem()?) 3) Or the function is not specified as public or in a scope that can be seen by your GUI class.
So check out that class and see which one it could be. If you still can't find it, post your NameRestock class code.
Thanks for looking at this with me! I have looked at the capitilizations and did not see any problems. I made sure the getnumItem and setnumItem functions were located in the file. They are both public. Hope you can help!
Here is error: E:\InFormation Technology Degree\IT215\Week Seven\inventory2>javac GUI.java GUI.java:122: cannot find symbol symbol : method getaryNum(int) location: class NameRestock NameRestock aryProd = (NameRestock) inventory.getaryNum(currentProdno); ^ 1 error
CODE
//NameRestock.java public class NameRestock extends Product { //the NameReStock subclass adds one field public String strCName;
// the NameRestock sublass has one Constructor public NameRestock(int prdItem, String prdName, int prdUnit, double prdPrice, String newName) { super(prdItem, prdName, prdUnit, prdPrice); strCName = newName; getstrCName();
} //end four-argument constructor
//the NameRestock subclass adds one method public void setName(String newName) { strCName = newName; }
My bad!! That was a tested error. I have the code back to original! Trying to figure it out!
Here is the error: E:\InFormation Technology Degree\IT215\Week Seven\inventory2>javac GUI.java GUI.java:122: cannot find symbol symbol : method getnumItem(int) location: class NameRestock NameRestock aryProd = (NameRestock) inventory.getnumItem(currentProdno);
QUOTE(letthecolorsrumble @ 6 Mar, 2008 - 01:19 PM)
Anyway you see it, getnumItem() method would return an int. But you want to create an object of NameRestock, so there is definitely a type mismatch.
Also in your NameRestock class getnumItem() does not take any arguments.
^^ He is certainly right on this one on both counts. Told you the error was back in NameRestock.
And as I told you, someone else could jump in and answer this before I could get back to you. That is the benefit of keeping your questions on the board rather than me answering this in PM for you. DIC is a team oriented environment.
Having commented out the "//NameRestock aryProd = (NameRestock) inventory.getnumItem(currentProdno);" and it does compile at this point. Realizing I have some getNumItem() issues. Shouldn't I be able to view its present contents. How do I kick this off?
"This is the fourth post that your're making about the same program. but your' not posting all the code. this way other people may not know what you're talking about without going back to the other posts."
*Now solution: 1) go to InventoryPart1.java and instantiate GUI -- like this
java
NameRestock aryProd[] = new NameRestock[4];
aryProd[0] = new NameRestock(1, "Hammers", 5, 20.12,"JBSandoz"); aryProd[1] = new NameRestock(2, "Electric Drills", 3, 78.39,"ToolTime"); aryProd[2] = new NameRestock(3, "Nails", 600, .15,"NailRoom"); aryProd[3] = new NameRestock(4, "Wood Screws", 300, .99,"WoodHouse");
//Sort Products. SortProductArray(aryProd); //call Bubble Sorth method System.out.println();//blank line
// this is where you instantiate // create GUI -- your passing ARRAY so go to the constructor and check parameter to ARRAY GUI gui = new GUI( aryProd );
this is what you should get after compiling -- But, as you can see you still have do so some work with the GUI ( user interface )
"This is the fourth post that your're making about the same program. but your' not posting all the code. this way other people may not know what you're talking about without going back to the other posts."
*Now solution: 1) go to InventoryPart1.java and instantiate GUI -- like this
java
NameRestock aryProd[] = new NameRestock[4];
aryProd[0] = new NameRestock(1, "Hammers", 5, 20.12,"JBSandoz"); aryProd[1] = new NameRestock(2, "Electric Drills", 3, 78.39,"ToolTime"); aryProd[2] = new NameRestock(3, "Nails", 600, .15,"NailRoom"); aryProd[3] = new NameRestock(4, "Wood Screws", 300, .99,"WoodHouse");
//Sort Products. SortProductArray(aryProd); //call Bubble Sorth method System.out.println();//blank line
// this is where you instantiate // create GUI -- your passing ARRAY so go to the constructor and check parameter to ARRAY GUI gui = new GUI( aryProd );
this is what you should get after compiling -- But, as you can see you still have do so some work with the GUI ( user interface )
Thank you for Helping! I will post all future posting to this post only! I did try to put all the code I am using. Guess I am not using the posting tools properly. So I have posted a text file that holds the code for each file. Would appreciate any feedback possible! I am seeking to understand in the minimal timeframe left!
Again Thanks!
Also, I notice you built your own GUI to check the Inventory program. I am compiling my GUI presently and it compiles properly. I realize this is not necessarily true. Apparently something is terribly wrong. Maybe I need to start from scratch. Hope not! Feedback appreciated!
This post has been edited by MFam: 6 Mar, 2008 - 07:14 PM
Also, I notice you built your own GUI to check the Inventory program
No, this is the same code that you wrote, i just had to change some variable and modify the constructor parameter to be an array.
here are the .java files: Product.txt ( 2.02k )
Number of downloads: 36 NameRestock.txt ( 1.32k )
Number of downloads: 34 InventoryPart1.txt ( 4.25k )
Number of downloads: 33 GUI.txt ( 6.25k )
Number of downloads: 33