Results 1 to 4 of 4
  1. #1
    BenH is offline Member
    Join Date
    Dec 2011
    Posts
    48
    Rep Power
    0

    Default 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]);
    
                }
    
      	}
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default 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.

  3. #3
    BenH is offline Member
    Join Date
    Dec 2011
    Posts
    48
    Rep Power
    0

    Default Re: Error: Cannot find symbol: Help!

    Quote Originally Posted by Fubarable View Post
    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.
    This is for a school assignment. I am supposed to create a subclass of the InventoryCal class. I am supposed to show my knowledge of inheritance. Did I not do it correctly?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Error: Cannot find symbol: Help!

    Quote Originally Posted by BenH View Post
    This is for a school assignment. I am supposed to create a subclass of the InventoryCal class. I am supposed to show my knowledge of inheritance. Did I not do it correctly?
    No you didn't. Again, it's not supposed to be an inner class. Give it its own file (again!).

Similar Threads

  1. Cannot Find Symbol Error
    By javadummy1 in forum New To Java
    Replies: 6
    Last Post: 04-09-2011, 10:13 AM
  2. Cannot find symbol Error
    By new_Java in forum New To Java
    Replies: 3
    Last Post: 02-17-2011, 11:23 PM
  3. Cannot find symbol error
    By rajivjoshi in forum New To Java
    Replies: 3
    Last Post: 05-31-2010, 10:13 AM
  4. Replies: 9
    Last Post: 10-18-2008, 08:26 PM
  5. 'Cannot find symbol' error
    By minihazard10 in forum New To Java
    Replies: 6
    Last Post: 10-10-2008, 04:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •