Hi...I have created a private static main method which instantiates an array of 3 different types of objects depending on the choices entered in on the command line. Here is my code:

 public static void main(String[] args)
    {
        //creates local variable currentIndex

        //creates employee array of type worker which can hold up to 100 emloyee objects
        Worker[] employee = new Worker[100];
        //do/while loop 
         int i = 0;
         do{         
            //if "w" for "worker" is entered, call Worker Class constructor, store 
            //pointer to worker name in employee array
            if (args[i].equalsIgnoreCase("w"))          
            {
               //store worker name in employee array
               employee[currentIndex] = new Worker(args[i+1]);
               //increment currentIndex counter by 1
               currentIndex++;
               //increment counter i by 2 
               i+=2;
            } 

            //if "p" for "producer" is entered, call Producer Class constructor, store 
            //pointer to producer name and prod. target in employee array
            else if (args[i].equalsIgnoreCase("p"))
            {  
               //store producer name in next avail array slot, morph string value for
               //production target and store as integer in next array slot
               employee[currentIndex] = new Producer(args[i+1], Integer.parseInt(args[i+2]));
               //increment currentIndex counter by 1                                        
               currentIndex++;
               //increment counter i by 2 
               i+=3;

            }    
            //if "m" for "manager" is entered, call Manager Class constructor, store 
            //pointer to manager name, number of subordinates, and whether or not this
            //manager is liked in next array slot
            else if (args[i].equalsIgnoreCase("m")){
            //store manager name in next avail array slot, morph string value for
            //number of subordinates and store as integer in next array slot along with
            //liked/disliked result in following slot
            employee[currentIndex] = new Manager(args[i+1], Integer.
                                                parseInt(args[i+2]), args[i+3]);
               //increment currentIndex counter by 1                                        
               currentIndex++;
               //increment counter i by 2 
               i+=4;
               }
               else 
               {
               //if choice was entered other than m,p,w, print error message
               System.out.println("Must be M, P, or W"); 
               //exit program
               System.exit(1);
               }    
           //end while loop    
           }while(i <args.length); 
        }
}//end class

I am supposed to create a private static method which is called by this main class once the array has been instantiated and called if the "Producer" class has an integer value greater than 50 (this is the parseInt(args[i+2]) in the Producer constructor call).

I can't quite get it to work.

Am trying to use this code:

       for (int j =0; j < employee.length; j++){
            if (employee[j].equals("Producer"))
            {
            System.out.println(Producer(args[j+1], (args[j +1],                                       Integer.parseIntargs[j+2]));

            }
}

I keep getting an error - cannot resolve method Producer(java.lang.string, int)

any help?

thanks.

If producer is static, then you shouldn't be calling it using the new keyword. It should be, ClassName.methodName().

I would have thought that would cause a "non static method being called from a static context" error though. Since that wasn't your error, then it could be that your method signature isn't correct, or that the parameter list isn't correct.

By the way, use code tags so your code is easier to look at.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.