Results 1 to 9 of 9
  1. #1
    kkid is offline Senior Member
    Join Date
    Jul 2012
    Posts
    241
    Rep Power
    3

    Default User interaction command-line

    I have to make a booking system for a theatre for some school coursework.

    I have little java experience so am learning as I create it.

    The program will be command-line as I will gain no extra marks from a GUI so it would just waste time (even though I have already had a quick look at swing).



    I want the program to give a list of options e.g:

    1. Show todays date
    2. show number of available seats
    3. Close program


    and the user would then input either 1, 2 or 3 into the CMD and hit enter for the relevant action to take place.



    What do I need to learn for this?
    Are there any tutorials in particular you would suggest i look at?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: User interaction command-line

    Quote Originally Posted by kkid View Post
    What do I need to learn for this?
    Are there any tutorials in particular you would suggest i look at?
    Here's a good place to start: Trail: Learning the Java Language (The Java™ Tutorials)

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,680
    Blog Entries
    7
    Rep Power
    21

    Default Re: User interaction command-line

    Read about the Scanner class and the several Reader classes for starters.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    kkid is offline Senior Member
    Join Date
    Jul 2012
    Posts
    241
    Rep Power
    3

    Default Re: User interaction command-line

    Quote Originally Posted by DarrylBurke View Post
    Isn't that just Oracles entire Java tutorial?
    I've already covered the basics, it is just this part which I want to learn at the moment.


    Quote Originally Posted by JosAH View Post
    Read about the Scanner class and the several Reader classes for starters.

    kind regards,

    Jos
    Thanks, I have came across these recently, I just wanted to make sure that this was what I was meant to be using.

  5. #5
    kkid is offline Senior Member
    Join Date
    Jul 2012
    Posts
    241
    Rep Power
    3

    Default Re: User interaction command-line

    The final thing I need to know before i think I know everything I need to create my program is how to make my own files which can be created, saved and then read by the java program I create. is this possible?


    i.e. I want the program to be able to create/update a text file which will store the variables of the program (whether a seat is booked and who it is booked by etc...)

    I want this so that all of the work is not lost when I terminate the program.

  6. #6
    kkid is offline Senior Member
    Join Date
    Jul 2012
    Posts
    241
    Rep Power
    3

    Default Re: User interaction command-line

    I don't think I explained very well.

    For example, if a seat was booked using the program. The program would write to a text file: seat1Astatus = booked; seat1AUser = "Gary Green";

    The text file could contain lots of these for each seat, when looking whther a seat is booked, we could just look up a variable listed in the text file.

    By storing it in an external text file, I would be able to have the main java program shut-down without everything being lost (i.e. the variables for the seats are stored on the hard drive instead of in memory)

  7. #7
    kkid is offline Senior Member
    Join Date
    Jul 2012
    Posts
    241
    Rep Power
    3

    Default Re: User interaction command-line

    btw, the text file isn't necassarily going to be variable statements, it could just be booked, unbooked, unbooked, unbooked, booked etc... where a comma separates each seat.



    Just ideas, I don't know if/how this can work

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,680
    Blog Entries
    7
    Rep Power
    21

    Default Re: User interaction command-line

    Maybe a Properties object can be of help; if you don't mind writing/reading non-text files, the Serializable framework can be a solution. It's time to start reading the tutorial ;-)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  9. #9
    kkid is offline Senior Member
    Join Date
    Jul 2012
    Posts
    241
    Rep Power
    3

    Default Re: User interaction command-line

    I've heard of properties files, I'll take a look, thanks

Similar Threads

  1. Developing an app without user interaction
    By StateMachine in forum Android
    Replies: 0
    Last Post: 12-31-2011, 08:30 AM
  2. Replies: 16
    Last Post: 09-17-2011, 03:41 AM
  3. can i run line by line command in netbean?
    By choconlongxu in forum NetBeans
    Replies: 1
    Last Post: 07-19-2010, 09:41 PM
  4. Replies: 2
    Last Post: 07-02-2010, 03: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, 01: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
  •