Basically I have to classes interacting with one another in this situation one company and one the driver, this code is written in the driver. So I am using a file reader to scan a text file that looks like this with a space between each line.
John:Smith:Manufacturing:6.75:120:444
Betty:White:Manager:1200.00:111
Stan:Slimy:Sales:10000.00:332
Betty:Boop:Design:12.50:50:244
And the code is as follows. The addEmployee method of the company class has a (string, string, string, double, int, int) parameter. The text file it reads in has a colons inbetween each part, so howe can I add it to the arraylist of objects. And keep going until all of them are read. Sorry if my questions difficult to understand, if you want me to elaborate let me know in the comments. I just didn't want to make the question too long.
else if (e.getSource()==readButton){
JFileChooser fileChooser = new JFileChooser("src");
if (fileChooser.showOpenDialog(null)==JFileChooser.APPROVE_OPTION)
{
empFile=fileChooser.getSelectedFile();
}
Scanner scan = new Scanner("empFile");
while(scan.hasNext()){
scan.next().split(":");
if (position.equals("Manager")){
c.addEmployee(fName, lName, position2, Double.parseDouble(firstParam2), 0, Integer.parseInt(empNum2));
}
else if(position.equals("Sales")){
c.addEmployee(fName, lName, position2, Double.parseDouble(firstParam2), 0, Integer.parseInt(empNum2));
}
else{
c.addEmployee(fName, lName, position2, Double.parseDouble(firstParam2), Integer.parseInt(secondParam2), Integer.parseInt(empNum2));
}
}