Sunday, April 14, 2013

"Cannot Find Symbol" Error, Stumped! - Java | Dream.In.Code


Example
#{example}
"); ipb.editor_values.get('templates')['togglesource'] = new Template("
??? Cancel Source Edit
"); ipb.editor_values.get('templates')['toolbar'] = new Template(""); ipb.editor_values.get('templates')['button'] = new Template("
  • Icon
  • "); ipb.editor_values.get('templates')['menu_item'] = new Template("
  • #{title}
  • "); ipb.editor_values.get('templates')['togglesource'] = new Template("
    ??? Cancel Source Edit
    "); ipb.editor_values.get('templates')['emoticons_showall'] = new Template(""); ipb.editor_values.get('templates')['emoticon_wrapper'] = new Template("

    Emoticons

    "); // Add smilies into the mix ipb.editor_values.set( 'show_emoticon_link', false ); ipb.editor_values.set( 'bbcodes', $H({"snapback":{"id":"1","title":"Post Snap Back","desc":"This tag displays a little linked image which links back to a post - used when quoting posts from the board. Opens in same window by default.","tag":"snapback","useoption":"0","example":"[snapback]100[/snapback]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"topic":{"id":"5","title":"Topic Link","desc":"This tag provides an easy way to link to a topic","tag":"topic","useoption":"1","example":"[topic=1]Click me![/topic]","switch_option":"0","menu_option_text":"Enter the topic ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"post":{"id":"6","title":"Post Link","desc":"This tag provides an easy way to link to a post.","tag":"post","useoption":"1","example":"[post=1]Click me![/post]","switch_option":"0","menu_option_text":"Enter the Post ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"spoiler":{"id":"7","title":"Spoiler","desc":"Spoiler tag","tag":"spoiler","useoption":"0","example":"[spoiler]Some hidden text[/spoiler]","switch_option":"0","menu_option_text":"","menu_content_text":"Enter the text to be masked","single_tag":"0","optional_option":"0","image":""},"acronym":{"id":"8","title":"Acronym","desc":"Allows you to make an acronym that will display a description when moused over","tag":"acronym","useoption":"1","example":"[acronym='Laugh Out Loud']lol[/acronym]","switch_option":"0","menu_option_text":"Enter the description for this acronym (EG: Laugh Out Loud)","menu_content_text":"Enter the acronym (EG: lol)","single_tag":"0","optional_option":"0","image":""},"hr":{"id":"12","title":"Horizontal Rule","desc":"Adds a horizontal rule to separate text","tag":"hr","useoption":"0","example":"[hr]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"1","optional_option":"0","image":""},"php":{"id":"14","title":"PHP Code","desc":"Allows you to enter PHP code into a formatted/highlighted syntax box","tag":"php","useoption":"0","example":"[php]$variable = true;\n\nprint_r($variable);[/php]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"html":{"id":"15","title":"HTML Code","desc":"Allows you to enter formatted/syntax-highlighted HTML code","tag":"html","useoption":"0","example":"[html]\n \n[/html]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"sql":{"id":"16","title":"SQL Code","desc":"Allows you to enter formatted/syntax-highlighted SQL code","tag":"sql","useoption":"0","example":"[sql]SELECT p.*, t.* FROM posts p LEFT JOIN topics t ON t.tid=p.topic_id WHERE t.tid=7[/sql]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"xml":{"id":"17","title":"XML Code","desc":"Allows you to enter formatted/syntax-highlighted XML code","tag":"xml","useoption":"0","example":"[xml]\n \n Test\n \n[/xml]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"member":{"id":"31","title":"Member","desc":"Given a member name, a link is automatically generated to the member's profile","tag":"member","useoption":"1","example":"[member=skyhawk133] runs this site.","switch_option":"0","menu_option_text":"Input Username of Member","menu_content_text":"","single_tag":"1","optional_option":"0","image":"memberbbcode.png"},"extract":{"id":"33","title":"Extract Blog Entry","desc":"This will allow users to define an extract for an entry. Only this piece of the entry will be displayed on the main blog page and will show up in the RSS feed.","tag":"extract","useoption":"0","example":"[extract]This is an example![/extract]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"blog":{"id":"34","title":"Blog Link","desc":"This tag provides an easy way to link to a blog.","tag":"blog","useoption":"1","example":"[blog=100]Click me![/blog]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"entry":{"id":"35","title":"Blog Entry Link","desc":"This tag provides an easy way to link to a blog entry.","tag":"entry","useoption":"1","example":"[entry=100]Click me![/entry]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"twitter":{"id":"36","title":"Twitter","desc":"A tag to link to a user's twitter account","tag":"twitter","useoption":"0","example":"[twitter]userName[/twitter]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":"twitter.png"},"inline":{"id":"37","title":"Inline Code","desc":"Formats code inline instead of in a seperate code box. ","tag":"inline","useoption":"0","example":"[inline]style=\"font-size: 12px;\"[/inline]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"il":{"id":"38","title":"Abbreviated Inline (IL)","desc":"Abbreviated version of the [inline] tag. ","tag":"il","useoption":"0","example":"[il]Code Here[/il]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":"il2.png"},"code":{"id":"41","title":"Code","desc":"Allows you to enter general code","tag":"code","useoption":"1","example":"[code]$text = 'Some long code here';[/code]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"1","image":""}}) ); ipb.vars['emoticon_url'] = "http://cdn.dreamincode.net/forums/public/style_emoticons/default"; //Search Setup ipb.vars['search_type'] = 'forum'; ipb.vars['search_type_id'] = 32; ipb.vars['search_type_2'] = 'topic'; ipb.vars['search_type_id_2'] = 318506; //]]>

    3 Replies - 0 Views - Last Post: 6 minutes ago Rate Topic: -----

    #1 SheenMachine ?Icon User is online

    Reputation: 0

    • Posts: 7
    • Joined: 28-October 12

    Posted 48 minutes ago

    Hello everyone, I'm doing a project for my java class, but I've run into a problem with my code. There are 2 classes, but my problem resides in the RentalCarCompany class.
    Here is the Car class
    
	public class Car    {         private String carRenter; //describe each var       private int carNum;       private String carName;       private String carType;       private int carDoor;       private static double rate;       private int days;               /** 	   *Default constructor for class Car, sets values to default of 0 or null. 	   */       public Car()       {         carRenter = ""; 		  carNum = 0; 		  carName = ""; 		  carType = ""; 		  carDoor = 0; 		  rate = 0.0; 		  days = 0;       }       /** 		*Parameterized constructor for class Car, allows the parameters to be set to values other than null or 0. 		*@param renter    The car renter 		*@param number    The car number 		*@param name      The car name 		*@param type      The car type 		*@param door      The number of doors on the car 		*@param initRate  The rate the car is rented at 		*@param initDays  The number of days the car is rented for 		*/         public Car(String renter, int number, String name, String type, int door, double initRate, int initDays)       {              carRenter = renter;          carNum = number;          carName = name;          carType = type;          carDoor = door;          rate = initRate;          days = initDays;	        }       /** 		*@return The car renter 		*/       public String getCarRenter()       {          return carRenter;       } 		       /** 		*@return The car number 		*/          public int getCarNum()       {          return carNum;       }        		/** 		*@return The car name 		*/          public String getCarName()       {          return carName;       }        		/** 		*@return The car type 		*/       public String getCarType()       {          return carType;       }        		/** 		*@return The car's number of doors 		*/       public int getCarDoor()       {          return carDoor;       }        		/** 		*@return The rate the car is rented at 		*/       public static double getCarRate()       {          return rate;       } 		       /** 		*@return The number of days the car is rented 		*/       public int getNumOfDays()       {          return days;       }    	       /** 		*@param newRenter The new car renter 		*/	       public void setCarRenter(String newRenter)       {          newRenter = carRenter;       }    	 		/** 		*@param newNum The new car number 		*/       public void setCarNum(int newNum)       {          newNum = carNum;       }    	 		/** 		*@param newName The new car name 		*/       public void setCarName(String newName)       {          newName = carName;       }    	 		/** 		*@param newType The new car type 		*/        public void setCarType(String newType)       {          newType = carType;       }    	 		/** 		*@param newDoor The new number of doors on the car 		*/       public void setCarDoor(int newDoor)       {          newDoor = carDoor;       }    	 		/** 		*@param newRate The new rate the car is rented at 		*/       public void setCarRate(double newRate)       {          newRate = rate;       }    	 		/** 		*@param newDays The new number of days the car is rented 		*/       public void setNumOfDays(int newDays)       {          newDays = days;       }    	    //toString() method	       public String toString()       {          return("Car renter's name: " + getCarRenter() + "\n" +                 "Car number: " + getCarNum() + "\n" +             	 "Car name: " + getCarName() + "\n" +             	 "Car type: " + getCarType() + "\n" +             	 "Car door: " + getCarDoor() + "\n" +              	 "Rate: $" + getCarRate() + "\n" +              	 "Rented for " + getNumOfDays() + "days");       			        }		    }

    And the RentalCarCompany class

    
 /** * *@author  *@version 1.0 April 7th 2013 * */ public class RentalCarCompany {   Car[] theCars;   String name;   int totalDays;   double totalRate;   int doorCount2;   int doorCount4;   int rentCnt;   static final int NUM_CARS = 20;   static final int NOT_FOUND = -1;      public RentalCarCompany()   {     name = ""; 	 totalDays = 0; 	 totalRate = 0.0; 	 doorCount2 = 0; 	 doorCount4 = 0; 	 rentCnt = 0;   }      public RentalCarCompany(String compName)   {     compName = name; 	 theCars = new Car[NUM_CARS];   }      public double getTotalSales()   {   double sum = 0.0;   int i = 0;     for (Car c: theCars) 	 { 	   for (i = 0; i <= c.getLength(theCars); i++) //this is where the error is thrown 		{ 		  sum = c.getCarRate() + sum; 		} 	 }return sum;   }      public double getAvgDays()   {      }      public double getAvgRate()   {      }      public int get2DoorCount()   {     int count = 0; 	 for (Car c: theCars) 	 {  		if (c.getCarDoor() == 2) 		{ 		  count ++; 		}	  	 }return count;   }      public int get4DoorCount()   {     int count = 0; 	 for (Car c: theCars) 	 {  		if (c.getCarDoor() == 4) 		{ 		  count ++; 		}	  	 }return count;    }      public String printRentalList()   {      }       } 

    The problem starts when I compile the RentalCarCompany class, it throws an error saying "cannot find symbol" it occurs on line 42.

    I've tried looking through the API for Array, thinking it might be an error there. I've changed some things around which solved multiple errors I had before, but this one won't stop popping up. Its got me stumped! Any help is appreciated!


    Is This A Good Question/Topic? 0

    Replies To: "Cannot Find Symbol" Error, Stumped!

    #2 g00se ?Icon User is online

    Reputation: 2030

    • Posts: 8,476
    • Joined: 20-September 08

    Re: "Cannot Find Symbol" Error, Stumped!

    Posted 17 minutes ago

    You need
    
   public double getTotalSales() {         double sum = 0.0;          for (Car c : theCars) {             sum += c.getCarRate();         }          return sum;     } 


    #3 SheenMachine ?Icon User is online

    Reputation: 0

    • Posts: 7
    • Joined: 28-October 12

    Re: "Cannot Find Symbol" Error, Stumped!

    Posted 14 minutes ago

    Thank you, that works! But, why does it work?


    #4 g00se ?Icon User is online

    Reputation: 2030

    • Posts: 8,476
    • Joined: 20-September 08

    Re: "Cannot Find Symbol" Error, Stumped!

    Posted 6 minutes ago

    Well it removes the error of trying to treat the array in some odd way twice (that you were doing)


    Page 1 of 1


    Source: http://www.dreamincode.net/forums/topic/318506-cannot-find-symbol-error-stumped/

    Comcast Pokemon X and Y Rob Ryan bethenny frankel sacramento kings alex jones Google Docs

    No comments:

    Post a Comment

    Note: Only a member of this blog may post a comment.