Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


CSC8012 Assessed Coursework: Interactive System


Submission Notes

You should submit four Java files and three text files through NESS as follows:

SortedArrayList.java, which contains your SortedArrayList<E> class for Task 1.

Event.java, which contains your Event class for Task 2.

Client.java, which contains your Client class for Task 2.

MainProgram.java, which contains your MainProgram driver class for Task 2; your main function should be in this class.

input.txt, which is the input file for your program (this can be the same as the provided input.txt file).

clerk.txt should contain a record of the clerk’s interactions with the program displayed in the Ter-minal Window (both what the clerk inputs and what your program prints out; copy and paste this from the Terminal Window in IntelliJ).

letters.txt should be the output file created by your program, which contains the letters to clients.

Your text files should show that you have tested your program.


Aims

To gain experience in designing an interactive system of practical importance.

To reinforce your knowledge about the standard java.util.ArrayList<E> class.

To gain experience at using the java.lang.Comparable<E> interface, inheritance and generic classes in Java.


Background

Sometimes we want to keep the items in a list in sorted order, which we can achieve with a sorted list. The fundamental difference between a sorted list and an unsorted one is the “adding an item”/insertion method. Having a definition of a class for lists, we can obtain a sorted list class by altering the existing one or adding a new insertion method.


Specification

Task 1

Derive a SortedArrayList<E> class from the java.util.ArrayList<E> class in such a way that the items of a sorted array list are sorted in ascending order. This subclass of the ArrayList<E> class will be needed to complete Task 2 (see Additional Assumptions (2) below). You only need to provide your new inser-tion method in the SortedArrayList<E> class. You do not need to consider the other methods from the ArrayList<E> class that can modify the list.


Task 2

You are asked to write a program to help a Winter Olympics ticket office clerk in their work. Your program should read a list of available events and a list of registered clients from a file. The content of the input file should have the following form: The first line contains an integer representing the number of available events, and is followed by the information about the events (two lines for every event: one line containing the name of the event and the second one containing the number of tickets available for this event). The next line contains an integer representing the number of registered clients, followed by the information about the clients (one line for every client with their first name and surname). Example file content is given below (same as the input.txt file available from Canvas):

6
Curling
8
Snowboarding
4
Ski Jumping
66
Figure Skating
7
Ice Hockey
2
Bobsleigh
41
3
Anna Jones
Ted Smith
Michael Jones

The program should be able to store information about events and clients:

1. For each event, the information required is: the name of the event and the number of tickets left for this event.

2. For each client, the office should know their first name, surname and the chosen events together with the number of tickets bought for each of the events. We assume that a client can buy tickets for at most three events. We also assume that no two clients share both their first name and their surname.

After the initial information has been read from the file, the clerk will work with the program interactively. The program should display a menu on the screen offering a choice of possible operations, each represented by a lower case letter:

f - to finish running the program.

e - to display on the screen information about all the events.

c - to display on the screen information about all the clients.

b - to update the stored data when tickets are bought by one of the registered clients.

r - to update the stored data when a registered client cancels/returns tickets.

You should implement all the above operations.


Additional Assumptions

1. When f is selected, the program stops running and all the data is lost. The program could be extended to save all the data to a file, but this is not part of the project!

2. To store events and clients you should use your SortedArrayList<E> class. Events should be sorted in the ascending order of names of events. Clients should be sorted in the ascending order of their surnames. If two clients have the same surname, then their first names should decide their order. You may assume that each client has exactly one first name and exactly one surname.

3. When tickets for an event are ordered by a client, your program must check whether the client is a valid client, and that the event is on the list of the available events. If not, an appropriate message should be displayed on the screen. If the request is a valid one, the program should check whether there are enough tickets left for the ordered event. You may assume that in one transaction a client orders tickets for one event. If the tickets are not available (or there are not enough tickets), a note (in the form of a letter) should be printed to a file informing the client that the tickets are not available. You may assume that the order is either fully satisfied or not carried out at all. If the ordered number of tickets is available, the transaction should be processed and the stored information should be updated accordingly.

4. When tickets (a ticket) are (is) cancelled by a client, your program must check whether the client is a valid client, whether the event specified by the tickets is on the list of events and whether the tickets have been purchased by this client. If not, an appropriate message should be displayed on the screen. If the request is a valid one, the stored information should be updated accordingly. You may assume that a client can cancel tickets for only one event per one transaction.

5. We assume that the ticket office only sells the tickets initially allocated to it, serves only its registered clients and processes transactions sequentially, one after the other.


Marking Scheme

The total number of marks which can be awarded for this coursework is 50 and accounts for 40% of the module mark for CSC8012. Marks will be awarded as follows:

Event, Client, SortedArrayList<E> classes: 15 marks

Input and Output: 6 marks

Implementation of operations: 15 marks

Readability of code: 8 marks

Evidence of testing: 6 marks