Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-24-2008, 11:27 PM
Member
 
Join Date: Jul 2008
Posts: 24
Rep Power: 0
bri1547 is on a distinguished road
Default Help with Compile time errors
I am having trouble resolving some compile time errors that I am getting. Can anyone help? Below is the code and the error messages:

Code:
import java.io.PrintWriter;

import java.util.Scanner;

import java.util.Vector;




public class InventoryList extends Vector<Inventory>

{
	
   public enum EPosition
	
   {
		FIRST,
		PREVIOUS,
		NEXT,
		LAST
	};


      private int current = -1;

	
	
   public Inventory getCurrent()
	
   {
		
      if ( current != -1 )
			
         return elementAt(current);
		
      else
		
         return null;
		
	
   }
   
   public boolean isLast()
	
   {
		
      if ( current == size() - 1 )
			
         return true;
		
      else
			
         return false;

    }	
	
	

   public boolean add( Inventory item  )
	
   {
		
      boolean result = super.add( item  );
		
      if ( result == true )

         current = size() - 1;
		
         return result;
	
   }
	
	

   public void removeCurrent()
	
   {
		
      if ( current >= 0 )
			
         remove( current );

		
      if ( current >= size() )
			 
         current = size() - 1;
	
   }
   

   public void setCurrent( EPosition pos )
	
   {
		
      if ( isEmpty() )
		
      { 
         current = -1;

      }        		
		
      else
      {
		

	 switch (pos)
			
         {
				
            case FIRST:
					
            current = 0;
					
            break;
	
			
            case PREVIOUS:
					
            current += size();
					
            -- current;
					
            break;

			
            case NEXT:
					
            ++ current;
					
            break;
				

            case LAST:
					
            current = size() - 1;
					
            break;
			
         }
			
      current %= size();

      }		
   }
		
	

   public void replaceCurrent( Inventoryitem )
	
   {
		
      set( current, item  );
	
   }
	
	

   public Inventory[] asArray()
	
   {
		
      Inventory[] items = new Inventory[size()];
		
      return toArray(items);
	
   }
	
	

   public void write( PrintWriter pw )
	
   {
		
      pw.println( Inventory.getRestockingFee() );
		
      pw.println();
		
		
      for( Inventory item : this )
		
      {
			
         item.write( pw );
			
         pw.println();
		
      }

   }

	

   public void readFrom( Scanner sc )
	
   {
		
      clear();
		
      Inventory.setRestockingFee( sc.nextDouble() );
		
      while( sc.hasNextInt() )
		
      {
			
         int itemNumber = sc.nextInt();
			
         sc.nextLine();
			
         String itemName = sc.nextLine();
			
         String sellingVenue = sc.nextLine();
			
         int unitsInStock = sc.nextInt();
			
         double unitPrice = sc.nextDouble();
			
			
         Inventory item = new Inventory(itemNumber, itemName, sellingVenue, unitsInStock, unitPrice);
			
         add(item);
		
      }
		
	
   }

}
.\InventoryList.java:154: <identifier> expected
public void replaceCurrent( Inventoryitem )
^
.\InventoryList.java:154: cannot find symbol
symbol : class Inventoryitem
location: class InventoryList
public void replaceCurrent( Inventoryitem )
^
.\InventoryList.java:159: cannot find symbol
symbol : method set(int,java.lang.String)
location: class InventoryList
set( current, item );
^
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 08-25-2008, 12:09 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
Is line 154 inside your class? Hard to tell from the long listing you've posted.
Where is the set() method you are using on line 159 defined?
Is it in scope at that line?

public void replaceCurrent( Inventoryitem )
You need to add a variable name after the type. It looks like you meant to enter item.

Can you remove the extra blank lines when you post code. It makes the post TOO long.

Last edited by Norm; 08-25-2008 at 12:12 AM.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-25-2008, 12:22 AM
Member
 
Join Date: Jul 2008
Posts: 24
Rep Power: 0
bri1547 is on a distinguished road
Default
Norm,

Sorry for not taking out the extra spaces. As I was reading your post I noticed that I did not have a space between inventory and item in the method name. I put the space in and everything worked great! Thanks for your help!
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
makeButton errors ljk8950 AWT / Swing 12 08-10-2008 02:10 AM
help with these errors oceansdepth New To Java 3 04-16-2008 05:55 PM
Errors I don't understand MattyB New To Java 4 04-02-2008 12:55 AM
I have 3 errors after compiling coco Database 2 10-18-2007 10:32 AM
Errors in constructor ai_2007 Advanced Java 0 07-01-2007 06:35 PM


All times are GMT +2. The time now is 06:39 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org