Results 1 to 6 of 6
  1. #1
    Gagnrath is offline Member
    Join Date
    Jun 2013
    Posts
    9
    Rep Power
    0

    Default Command line menu question

    Hello,

    I am currently learning Java for my current college course and for my final project, I have to make a program for punching people in/out and maintaining simple profiles.

    What I am puzzled over is how to make a command line menu that uses multiple displays for each compontent (ie.

    in main screen, you press "1" and it clear the main menu and will bring you to the login in/out screen)

    So far I only have a println for the main screen which gives you the options and will ask for input. I'm guessing I need to make a seperate class for each of the options in the menu, but how do I go about making the menu structure the way I need to?

    Thanks in advance

  2. #2
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    354
    Rep Power
    5

    Default Re: Command line menu question

    If you just want standard keyboard interaction, you can use a combination of System.in.out.println() (for printing messages to the console) and the Scanner class(for taking in input from the keyboard). If you want something more interactive, look into Swing, which is JAVA's widget toolkit for creating Graphical User Interfaces.

    As far as maintaining profiles, are you using a relational database, like MySQL or Oracle, or are you using text files? If you are using a real database to store the user data, then you will need to look at JDBC, which is fairly simple to use. If the data is coming from a text file, look at examples of using a BufferedReader and a BufferedWriter.
    Last edited by sehudson; 07-29-2013 at 05:53 PM.

  3. #3
    Gagnrath is offline Member
    Join Date
    Jun 2013
    Posts
    9
    Rep Power
    0

    Default Re: Command line menu question

    Quote Originally Posted by sehudson View Post
    If you just want standard keyboard interaction, you can use a combination of System.in.out.println() (for printing messages to the console) and the Scanner class(for taking in input from the keyboard). If you want something more interactive, look into Swing, which is JAVA's widget toolkit for creating Graphical User Interfaces.

    As far as maintaining profiles, are you using a relational database, like MySQL or Oracle, or are you using text files? If you are using a real database to store the user data, then you will need to look at JDBC, which is fairly simple to use. If the data is coming from a text file, look at examples of using a BufferedReader and a BufferedWriter.
    The plan is to ultimately run the program in a normal prompt, so I will probably go the route of the scanner class, I'm just wondering if each output screen for the different pieces would need to be its own class.

    As for storing data, I found some good articles on how to store data via XML which would allow for generating a report to be easier as the data will have tags associated with each pieces, so I would only have to worry about formatting.

  4. #4
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    354
    Rep Power
    5

    Default Re: Command line menu question

    If you are doing it that way, there really are no 'screens' then, right?
    Are you thinking of printing instructions to the console, reading in the input, processing the input, write out another instruction, read in the input, process the input, repeat?

  5. #5
    Gagnrath is offline Member
    Join Date
    Jun 2013
    Posts
    9
    Rep Power
    0

    Default Re: Command line menu question

    Quote Originally Posted by sehudson View Post
    If you are doing it that way, there really are no 'screens' then, right?
    Are you thinking of printing instructions to the console, reading in the input, processing the input, write out another instruction, read in the input, process the input, repeat?
    So here is what I am trying to do, bear in mind, when the diagram was made, I was originally going to do a Visual GUI, but have decided to go command line instead.

    Command line menu question-milestone-1.jpg

  6. #6
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    354
    Rep Power
    5

    Default Re: Command line menu question

    Ok, so given that, you could create an Employee class if you wanted to in order to give your program some structure. That way, say for example someone is creating a new employee. As they enter data for the employee, you construct an Employee object, and at your "Store Employee Data" step, you can call a method like:


    Java Code:
    private void addNewEmployeeRecord(Employee newEmployee) {
    //code to add a new xml node to your file for the employee
    }

    One thing that I see is that for your punch in/out option, when does the user enter their id so that you know who is punching in/out? You have the flow layed out pretty well, other than the fact that as you said, it reflects some GUI interaction with buttons, etc.
    Last edited by sehudson; 07-29-2013 at 08:54 PM.

Similar Threads

  1. Replies: 4
    Last Post: 01-02-2013, 08:50 PM
  2. Command line question
    By dougie1809 in forum New To Java
    Replies: 1
    Last Post: 03-09-2012, 01:40 PM
  3. Replies: 16
    Last Post: 09-17-2011, 02:41 AM
  4. Replies: 2
    Last Post: 07-02-2010, 02:20 PM
  5. Unable to execute command line command in java
    By LordSM in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 12:23 AM

Posting Permissions

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