Results 1 to 4 of 4
Thread: Error: Cannot find symbol: Help!
- 02-05-2012, 11:50 PM #1
Member
- Join Date
- Dec 2011
- Posts
- 48
- Rep Power
- 0
Error: Cannot find symbol: Help!
Hi there!
I have almost finished my project, but I keep getting the error cannot find symbol error. I don't know why. I made sure everything was spelled correctly. Here is my code maybe you can help! I am getting the error at line 31 in the InventoryAdvanced class.
Java Code:/* Author: Ben Hartnett Sources: Java: A Beginner's Guide Source 2: Monster example posted on student forums Date Retrieved: 1-26-2012 */ public class InventoryAdvanced { public static void main(String args[]){ //Define the calculation variables double c1; double c2; double c3; //Declare the calculation variables c1 = 13.00; c2 = 5.00; c3 = 10.00; //Declare the 5% restocking fee double fee = .05; //Create the objects InventoryDefine swordstone = new InventoryDefine("Sword In The Stone Movie", 1, 10, 13.00, 130.00); InventoryDefine hercules = new InventoryDefine("Hercules Movie", 2, 20, 5.00, 100.00); InventoryDefine mermaid = new InventoryDefine("The Little Mermaid Movie", 3, 30, 10.00, 300.00); InventorySort sortThis = new InventorySort(); InventoryCal cal = new InventoryCal(); SwordStone movie = new SwordStone(); //Use an object to store the array InventoryDefine[] inventoryArray = new InventoryDefine[3]; //Declare the arrays inventoryArray[0] = swordstone; inventoryArray[1] = hercules; inventoryArray[2] = mermaid; //Call the method from the sortThis object sortThis.Sort(inventoryArray); //Call the method from InventoryCal cal.calVar(c1, c2, c3); //Override the method from InventoryInherit movie.calVar(c1, fee); } }Java Code:/** /* Author: Ben Hartnett Sources: Java: A Beginner's Guide Source 2: Monster example posted on student forums Date Retrieved: 1-26-2012 */ public class InventoryCal { //Create a method that multiplies the variables public void calVar(double m1, double m2, double m3){ //Create the calculation variable double calEquals; //Create the equation calEquals = m1 + m2 + m3; //Display the result System.out.println("Total inventory value:" + calEquals); } public class SwordStone extends InventoryCal { //Create the calculation method public void calVar(double m1, double restockFee){ //Create the calculation variable double calEquals; //Create the equation calEquals = m1 + 10 * restockFee; //Display the result System.out.println("Sword In The Stone product value with restocking fee:" + calEquals); } } }Java Code:/* Author: Ben Hartnett Sources: Java: A Beginner's Guide Source 2: Monster example posted on student forums Date Retrieved: 1-26-2012 */ //Create the class while it implements the Comparable public class InventoryDefine implements Comparable<InventoryDefine> { //Define the variables private String inventoryName; private int inventoryNumber; private int inventoryStock; private double inventoryPrice; private double inventoryValue; //Declare the constructor public InventoryDefine(String inventoryName, int inventoryNumber, int inventoryStock, double inventoryPrice, double inventoryValue){ this.inventoryName = inventoryName; this.inventoryNumber = inventoryNumber; this.inventoryStock = inventoryStock; this.inventoryPrice = inventoryPrice; this.inventoryValue = inventoryValue; } //Use the toString method public String toString() { return inventoryName + ", " + inventoryNumber + ", " + inventoryStock + ", " + inventoryPrice + ", " + inventoryValue; //Return values } //Use the compareTo method public int compareTo(InventoryDefine id){ return this.inventoryNumber - id.inventoryNumber; //Return values } }Java Code:/* Author: Ben Hartnett Sources: Java: A Beginner's Guide Source 2: Monster example posted on student forums Date Retrieved: 1-26-2012 */ import java.util.Arrays; public class InventorySort { public void Sort(InventoryDefine[] array){ Arrays.sort(array); for (int i = 0; i < 3; i++){ System.out.println(array[i]); } } }
-
Re: Error: Cannot find symbol: Help!
Your SwordStone class is defined inside of InventoryCal for no good reason that I can see and because of this, the compiler can't find it. Get it into its own Java class.
- 02-05-2012, 11:56 PM #3
Member
- Join Date
- Dec 2011
- Posts
- 48
- Rep Power
- 0
-
Re: Error: Cannot find symbol: Help!
Similar Threads
-
Cannot Find Symbol Error
By javadummy1 in forum New To JavaReplies: 6Last Post: 04-09-2011, 10:13 AM -
Cannot find symbol Error
By new_Java in forum New To JavaReplies: 3Last Post: 02-17-2011, 11:23 PM -
Cannot find symbol error
By rajivjoshi in forum New To JavaReplies: 3Last Post: 05-31-2010, 10:13 AM -
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 08:26 PM -
'Cannot find symbol' error
By minihazard10 in forum New To JavaReplies: 6Last Post: 10-10-2008, 04:05 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks