Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

command line interface mian program problem

Status
Not open for further replies.

penny123

Programmer
May 1, 2003
1
US
Hi,
im trying to construct the main program class in a java program and it has a command line interface, but im having trouble as i have to get the user to specify the number of machines they want at the command line, i've done this, but now i need this to be passed to a package which contains the machine class, so that the method addMachine is repeated the number of times the user specified(i.e. repeat addMachine method 4 times if user types in 4). This is the code i have so far for this bit:

import java.io.*;
public class CommandLineInterface
{
public static InputStreamReader input = new InputStreamReader(System.in);
public static BufferedReader keyboardInput = new BufferedReader(input);

int NumberOfProcessMachines;

System.out.print("How many processing machines do you require ?");
NumberOfProcessMachines = new Integer (keyboardInput.readLine()).intValue();
plant.addMachine("Processing", 20, 60, (float)1/100);

N.B. normally i'd repeat the line
plant.addMachine("Processing", 20, 60, (float)1/100);
as many times as i need, but this isn't good programming, , could anyone please give me any suggestions on how to do this.Thankyou
 
If you have control of the "addMachine" method, you could add a "number of machines parameter" to it?

Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top