Connecting Tech Pros Worldwide Forums | Help | Site Map

declaring an array in a client????

Newbie
 
Join Date: Apr 2007
Posts: 3
#1: Apr 28 '07
Hi

me here again. I have no clue what I am doing wrong. Here is the code we have written this far
Expand|Select|Wrap|Line Numbers
  1. import javax.swing.JOptionPane;
  2. import java.io.FileReader;
  3. import java.io.BufferedReader;
  4. import java.io.FileNotFoundException;
  5. import java.io.IOException;
  6. import java.util.StringTokenizer;
  7. import java.util.ArrayList;
  8.  
  9.  
  10. public class VendingMachineClient
  11. {
  12.     public static void main (String[]args)
  13.     {
  14.  
  15.         ArrayList<VendorClass> itemList = new ArrayList<VendorClass>();
  16.         int userChoice;
  17.  
  18.  
  19.         try
  20.         {
  21.             FileReader fr = new FileReader("Item.txt");
  22.             BufferedReader br = new BufferedReader(fr);
  23.  
  24.             //declare string variable and prime the read
  25.             String stringRead = br.readLine();
  26.  
  27.             while(stringRead != null) //end of file ?
  28.             {
  29.                 StringTokenizer st = new StringTokenizer(stringRead, ",");
  30.                 String item = st.nextToken();
  31.  
  32.                 try
  33.                 {
  34.                     int id = Integer.parseInt( st.nextToken());
  35.                     int stock = Integer.parseInt( st.nextToken());
  36.                     int price = Integer.parseInt( st.nextToken());
  37.  
  38.                     VendorClass frTemp = new VendorClass(id,item,stock,price);
  39.  
  40.                     itemList.add(frTemp);
  41.                 }
  42.  
  43.                 catch (NumberFormatException nfe)
  44.                 {
  45.                     JOptionPane.showMessageDialog(null, "Error in record: "
  46.                                         + stringRead + " record ignored");
  47.                  }
  48.  
  49.                  stringRead = br.readLine();
  50.             }
  51.  
  52.             br.close();
  53.         }
  54.  
  55.         catch (FileNotFoundException fnfe)
  56.         {
  57.             JOptionPane.showMessageDialog(null, "Unable to find Item.txt");
  58.         }
  59.  
  60.         catch (IOException ioe)
  61.         {
  62.             ioe.printStackTrace();
  63.         }
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.         String userMenu = JOptionPane.showInputDialog(null, "Please enter which mode you want to be in."
  79.                                                         + "\n Vendor Mode = 1"
  80.                                                         + "\n Buyer Mode = 2"
  81.                                                         + "\n To Quit  = 3");
  82.  
  83.         userChoice =Integer.parseInt(userMenu);
  84.  
  85.         while ((userChoice < 1) || (userChoice > 2))
  86.             {
  87.                 userMenu = JOptionPane.showInputDialog(null, "Please enter which mode you want to be in."
  88.                                                                         + "\n Vendor Mode = 1"
  89.                                                                         + "\n Buyer Mode = 2"
  90.                                                                         + "\n To Quit  = 3");
  91.  
  92.                 userChoice =Integer.parseInt(userMenu);
  93.             }
  94.  
  95.  
  96.  
  97.         /*if(userChoice == 1)
  98.         {
  99.  
  100.  
  101.         }
  102.  
  103.         else if
  104.         {
  105.  
  106.         }
  107.  
  108.         else
  109.         //close program*/
  110.  
  111.     }
  112. }


this is the error that is generated
Expand|Select|Wrap|Line Numbers
  1. C:\Documents and Settings\Ownerx\My Documents\final prog\VendingMachineClient.java:42: cannot find symbol
  2. symbol  : constructor VendorClass(int,java.lang.String,int,int)
  3. location: class VendorClass
  4.                     VendorClass frTemp = new VendorClass(id,item,stock,price);
  5.                                                              ^
  6. 1 error
  7.  
  8. Tool completed with exit code 1

i am hoping someone will be kind enough to tell me where the error is as I have no clue what that cryptic message is telling me.

We have a java file named VendorClass we have 2 text files named Item and Money

Please Please Please help


oh and I am sorry I have no clue how to do that funky code box thingy I know it is easier to read


Teresa

JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#2: Apr 28 '07

re: declaring an array in a client????


Did you compile your "VendorClass"? i.e. do you see a "VendorClass.class" file?

kind regards,

Jos
Reply