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?
Re: User interaction command-line
Quote:
Originally Posted by
kkid
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
Re: User interaction command-line
Read about the Scanner class and the several Reader classes for starters.
kind regards,
Jos
Re: User interaction command-line
Quote:
Originally Posted by
DarrylBurke
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
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.
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.
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)
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
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
Re: User interaction command-line
I've heard of properties files, I'll take a look, thanks