Help with inheritance/hierarchy
I was wondering if anyone knew how to write this code? Im confused on how to start...
– Open a text file (copied into your project main folder) for reading. Get the name
of the text file from args[0]. As always, make sure that args[0] is present and print an
appropriate message otherwise.
– Create an ArrayList<Employee> to hold the employees.
– Read in each line of the file which should be in the following format:
<name> <type> <hours> <wage> <salary>
Re: Help with inheritance/hierarchy
Which part of this are you having trouble with? What do you have so far?
Break the problem up into smaller steps, and do the steps one at a time. What's the next thing you know you have to do? (do you have a main method yet? How do you test that args[0] is present?)
Re: Help with inheritance/hierarchy
I have created the other classes of this project, but Im confused on how im supposed to create an array list from the text that i put in my text file? i have this so far but i dont think its correct
package prog5;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Prog5 {
public static void main(String[] args) {
//Open text file for reading
if (args.length != 1) {
System.out.println("Must specify file on the command line");
return;
}
try {
FileInputStream fStream = new FileInputStream(args[0]);
try (BufferedReader in = new BufferedReader(new InputStreamReader(fStream))) {
while (in.ready()) {
System.out.println(in.readLine());
}
}
} catch (IOException e) {
System.out.println("File input error");
}
//Create ArrayList
ArrayList Employee = new ArrayList();
}