trying to build a Java program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jasoncai
    New Member
    • Feb 2008
    • 5

    trying to build a Java program

    Im trying to build a java program that reads user's input as a command, currently, i want to make 2 commands: Enter and Quit
    if the user type Enter as a command, the program will run, if the user type Quit, the program will halt.
    how can i justify whether its a Quit command or a Enter command? Also, how can I vertify if they write the command in prefix, for example, instead of type Quit, the user typed Q, or Qu, or Qui, ignore the case 2.
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    #2
    Originally posted by jasoncai
    Im trying to build a java program that reads user's input as a command, currently, i want to make 2 commands: Enter and Quit
    if the user type Enter as a command, the program will run, if the user type Quit, the program will halt.
    how can i justify whether its a Quit command or a Enter command? Also, how can I vertify if they write the command in prefix, for example, instead of type Quit, the user typed Q, or Qu, or Qui, ignore the case 2.

    what do you mean?

    Actually if you do that, the program must run first, before you could read the user's input...
    It should be at the main method, trap the input, if Entered, then create an object for the class that is responsible for the main program flow...


    Or, if you mean that the user would pass a value to args[], then read the args[],
    compare them... Use string...

    Correct me if im wrong,
    Sukatoa (Shadow shaman)

    Comment

    • jasoncai
      New Member
      • Feb 2008
      • 5

      #3
      yea, the program will need to run first, i got that part, currently working how to differ different COMMAND, I hav 5 commands in this program, how can i direct each command to what they do.

      Comment

      • sukatoa
        Contributor
        • Nov 2007
        • 539

        #4
        Originally posted by jasoncai
        yea, the program will need to run first, i got that part, currently working how to differ different COMMAND, I hav 5 commands in this program, how can i direct each command to what they do.
        for example, you have classes Entered, Quit, Options, and Edit
        inside or outside the main class...

        if the user inputs Entered, or E or En or Ent, use the Strings to compare them...
        carefully trap them and if that is satisfied,
        call the Entered class.. and choose what soever methods are there...depends on what you implemented in there....

        like:
        Entered entered = new Entered(paramet ers if required);
        entered.startPr ogram(); like that....

        or if the user enters QUIT or Q or QU or QUI, use the String, trap them carefully and if satisfied, just simply terminate the program.... System.exit(0);


        correct me if im wrong,
        Sukatoa (Shadow Shaman)

        Comment

        • jasoncai
          New Member
          • Feb 2008
          • 5

          #5
          do you hav msn
          i hav plenty of questions

          Comment

          • sukatoa
            Contributor
            • Nov 2007
            • 539

            #6
            Originally posted by jasoncai
            do you hav msn
            i hav plenty of questions
            Im using Yahoo Messenger... You can post all your questions here... the advantage is that, Many programmers here are ready to help you... I am a Java lover...

            If you post your questions here, and hopefully answered correctly, i guess the incoming java beginners will need this thread...soon.. .

            Post your questions here..

            Regarding,
            Sukatoa (Shadow Shaman)

            Comment

            • jasoncai
              New Member
              • Feb 2008
              • 5

              #7
              ok, from the beginning, I want to read these command inputs from the user: Enter, Sort, Find, Display, Quit, ?.
              for "?", the program will tell the user all the commands.
              for "Enter", user gets to type some number
              for "sort", the program will sort the list user just typed in
              ....
              and the program will display this for user input: """"Data> (command from user)"""
              questions:
              1. how can I make the """Data>""" to display after the user finished 1 of the command, for ex, when the user finish the "Enter", how can i make the program to display """Data>""" again for him to use other command
              2. how to differ what command the user type, differ between "incorrect command", or "Enter" .....etc

              Im new to Java, just started it few weeks ago, so i dont really know what code to use to build this program. Can I have some tips?

              Comment

              • sukatoa
                Contributor
                • Nov 2007
                • 539

                #8
                Originally posted by jasoncai
                ok, from the beginning, I want to read these command inputs from the user: Enter, Sort, Find, Display, Quit, ?.
                for "?", the program will tell the user all the commands.
                for "Enter", user gets to type some number
                for "sort", the program will sort the list user just typed in
                ....
                and the program will display this for user input: """"Data> (command from user)"""
                questions:
                1. how can I make the """Data>""" to display after the user finished 1 of the command, for ex, when the user finish the "Enter", how can i make the program to display """Data>""" again for him to use other command
                2. how to differ what command the user type, differ between "incorrect command", or "Enter" .....etc

                Im new to Java, just started it few weeks ago, so i dont really know what code to use to build this program. Can I have some tips?
                60% of the java tips are found on ebooks bro....


                Ahhh, so you would like to create a program that is similar to DOS prompt's behavior?

                So, can you discuss what can the "ENTER" command do? What will happen if I typed the command "ENTER" then enter? What data is required to accomplish the ENTER COMMAND's task? Is this program for user or for programmer? (user friendly or for experimental purposes)?

                [PHP]for "?", the program will tell the user all the commands.
                for "Enter", user gets to type some number
                for "sort", the program will sort the list user just typed in[/PHP]

                User gets to type a number?
                the program will sort the list user just typed in?

                Can you clarify every command's task?

                the program will sort the list? What list? those numbers that the user inputted a while ago?

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Originally posted by sukatoa
                  60% of the java tips are found on ebooks bro....


                  Ahhh, so you would like to create a program that is similar to DOS prompt's behavior?

                  So, can you discuss what can the "ENTER" command do? What will happen if I typed the command "ENTER" then enter? What data is required to accomplish the ENTER COMMAND's task? Is this program for user or for programmer? (user friendly or for experimental purposes)?

                  [PHP]for "?", the program will tell the user all the commands.
                  for "Enter", user gets to type some number
                  for "sort", the program will sort the list user just typed in[/PHP]

                  User gets to type a number?
                  the program will sort the list user just typed in?

                  Can you clarify every command's task?

                  the program will sort the list? What list? those numbers that the user inputted a while ago?
                  java.util.Scann er will have to be mentioned at some point in this thread.
                  What code have you written so far?

                  Comment

                  Working...