Results 1 to 3 of 3
  1. #1
    klz215 is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default 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>

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,889
    Rep Power
    8

    Default 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?)
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    klz215 is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default 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();



    }

Similar Threads

  1. How to pass events up a GUI hierarchy
    By robbie.26 in forum AWT / Swing
    Replies: 14
    Last Post: 06-28-2011, 03:14 PM
  2. STRUTS 2 project folder hierarchy
    By buyapentiumjerk in forum Web Frameworks
    Replies: 3
    Last Post: 06-18-2011, 05:50 PM
  3. catching exceptions (hierarchy)
    By kailash in forum Java Servlet
    Replies: 2
    Last Post: 02-10-2011, 06:43 AM
  4. Hierarchy in Project
    By efozdel in forum New To Java
    Replies: 4
    Last Post: 07-23-2010, 09:49 AM
  5. Replies: 6
    Last Post: 07-04-2010, 04:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •