CSIT212
Assignment 2 : Shell Programming
The objective of this assignment is to be familiar with bash Shell programming.
This assignment requires you to write a portion of the self-service ticketing kiosk for a cinema using the Bourne-Again Shell (bash). The self-service ticketing system will allow the public to check the availability of the cinema tickets for a particular movie and choose their own seating in the theatre as well as to purchase tickets themselves. A suggested interactive ticketing menu with color can be as follows:
Main Menu
ROCKY Theatre’s Self-service Ticketing
- List all Movies and Show times
- Fast booking (where system will automatically select best seat)
- To select theatre’s seat manually
- Search by Show time or movie title
- Quit
Best seats are the seats in the center and in the first 10 rows
For a color menu, one can use the following template for writing colored text on a colored background.
echo -e '\E[COLOR1;COLOR2mSome text goes here.'
Choice 1 of the main menu will provide a list of all the movies and show times the theatre are screening. The list of movies can be populated from a flat file. Below is a sample of the file format with comma as the delimiter. You can add in extra fields if required.
[Showtimes], |
[Movie Title], |
[Vacancy] |
1300 – 2Oct, |
UnderCovers, |
Yes |
1600 – 2Oct, |
RoboCop, |
No |
1700 – 2Oct, |
Predators, |
Yes |
While generating this list of movies for display, you are to include if the movies are sold out or still available by checking on the flat in the file. You are to use stream editor (sed) command to assist in the report generation by checking the vacancy column with the substitution of “Yes” with “SOLD OUT” for the respective movies and “No” with “Ticket available”. Simultaneously you are to use sed to swap the column of the Movie Title and Showtimes as your program read from the file. Sample output can be as follows:
ROCKY Theatre’s Screening Movies
Movie Title | Showtimes | Vacancy |
UnderCovers | 1300-2Oct | Ticket available |
RoboCop | 1600-2Oct | SOLD OUT |
Predators | 1700-2Oct | Ticket available |
Choice 2 is a quick way of ticket purchase where the system has some intelligence in generating the next optimum available seat for customer to make a quick purchase. You can assume that the seats which are nearer to the screen and more centralized are the better ones.
Choice 3 will display the seats that are available as well as not, in a matrix or pattern as shown below. You can use a while loop to implement this.
For both fast and manual booking, the ticketing system can also compute the total price chargeable as shown above.
Choice 4 will allow customer to search by show times or by movie title. For instance, the customer might like to find out what movies are there screening at 19:00. You can use commands like egrep or grep coupled with regular expressions such as ^, $, [] etc to search through the records.
You will need to create a file system so that the system will know the seat vacancies for the different movies at different show times. Some entries validation is required to check if the seat number entered is valid or available for sales. Bonus marks will be given for any other ticketing features implemented.
In your shell program, you can use commands such as echo, grep, awk, cut, >>, read, expr, sort etc. to store, locate, display, remove and sort. If else control structure, case structure, while and for loop can be incorporated as well.
Execution of your program would be as follows:
$bash ticketing.sh or $ticketing.sh
Grading:
Your submission would be graded according to the following criteria:
- Functionality – 4%
- Efficiency and implementation as per instructions – 4%
- Comments – 1%
- Readme file - 1%
Submission
You are to submit a media containing :-
- course cover sheet
- your shell script
- a text file (named Readme) containing instructions on how to run your utility and the status of your utility e.g. not completed or special features etc.
- Submit the above as a single file
- For submission, pls drop your zip file into moodle website.