Specification
Overview
The Sandfly Creek Fishing Club is to host its annual fishing
competition. As the only
member of the club who has any knowledge of computers, you have
volunteered to
write a program to handle the event. The competition, which runs over
three days,
allows anglers to submit any number of entries in each of the
following fish
categories:
An entry consists of a weight, recorded to three decimal places, of a
particular fish
for a particular angler. The system is only required to maintain the
best entry
(greatest weight) to date for each angler-fish type combination. It
should be capable
of storing up to a maximum of 100 such entries. The following data
should be
recorded for each entry:
At the end of the first and second days the recorded entries are
stored to disk for
retrieval on the following day. Entries are to be stored on disk in
fixed-length binary
format. When entries are updated to an existing file, the entire file
is overwritten with
the entries stored in memory.
A facility must be provided to display the current entries grouped by
fish category,
with angler's names in alphabetical order within each fish category.
The current
Barramundi
Bream
Whiting
Flathead
PikeyEel
Catfish
Shark
Allowable Fish Categories
fish type in one of the above fish categories
angler name up to a maximum of 30 characters
weight recorded to 3 decimal places
entries will be checked at the end of each day for possible errors. A
facility to delete
such erroneous entries must be provided.
At the end of the three-day competition the system will determine an
overall winner
the angler (or anglers there may be a multi-way tie) with the
weightiest fish over all
categories and a winner (or winners multi-way category-ties are
also possible) in
each fish category.
As a member of the Queensland Amateur Fishing Association the Sandfly
Creek
Fishing Club is required by law to display, in conjunction with the
winners list, any
judge's rulings made during the competition. The club has decided to
comply with
this law in a minimalist fashion. The various rulings a judge can make
are laid down
in numbered sequence, 1 to 7999, in the Queensland Amateur Fishing
Association
Competition Rules Book.
The rulings are categorised as follows:
1 to 5999 represent Denial of Protest rulings
6000 to 7999 represent Protest Upheld rulings
On the final day of the competition (prior to generating the winners
list), the system
will allow for the entry of judge's rulings, with each ruling being
designated by the
entry of a number in the range 1 to 7999. Although there are typically
few judge's
rulings at a competition, the system must be capable of dealing with
any number of
such rulings. However, there is no requirement for storing rulings to
disk.
When the winners list is generated, it will be preceded by a list of
the judges rulings,
with each ruling showing an indication of its Denial/Upheld status.
Detail View
The program initially displays a heading identifying the competition
and the types of
fish which will be accepted. If the binary file Entries.dat exists,
the data are read into
memory and the user is given the option of using the existing data. If
the user does
not choose to use this data, it will be discarded and the file will be
overwritten with
any new data entered (if option 6 Save the entries to file, is
chosen). A typical screen
snapshot, upon entry to the system, is shown below.
The following menu is then displayed.
Option 1: Display all entries
During the competition, entries are displayed to the screen in the
following columnar
format:
Fishing Competition .. Sandfly Creek .. 2003
============================================
The types of fish we accept are:
1. Barramundi
2. Bream
3. Whiting
4. Flathead
5. PikeyEel
6. Catfish
7. Shark
Do you wish to use the existing data?
Fishing Competition MENU
========================
1. Display all entries
2. Add new entries
3. Delete entries
4. Enter judge's rulings
5. Display the winners
6. Save the entries to file
0. Exit the program
Enter your choice
Angler Fish Weight
Harvard, David Barramundi 3.000
Jackson, Peter Barramundi 4.000
Weston, Dolly Bream 3.000
Press enter to continue
During the competition, the entries are to be displayed, grouped by
fish type, and in
alphabetical order of angler name within each fish-type group (See the
hint in Option
2: Add new entries).
On the final day of the competition, after the winners list has been
displayed (and
entries have been sorted into weight order), selection of this option
will cause all
entries to be displayed in descending order of weight.
Since there are possibly up to 100 entries, the system must allow the
user to view
entries one screenful at a time.
If there are no entries, an appropriate message is displayed.
Option 2: Add new entries
This option allows the user to enter any number of new entries. The
angler's name,
the type of fish and the weight are input. If an entry already exists
for this angler-fish
combination, then:
if the new weight is greater than the existing-entry weight,
the old entry is
replaced with the new entry and an appropriate advisory message and
details of the new entry are displayed.
if the new weight is no greater than the existing-entry
weight, an
appropriate advisory message along with the existing entry details are
displayed.
If an entry does not already exist for this angler-fish type, the
entry is added and an
advisory message and the entry details are displayed.
The system must ensure that array bounds overflow does not occur while
entering
new data. If, for example, entries are stored in memory in a
100-element array, the
system must prevent the user from making more than 100 entries.
An error message should be generated if an attempt is made to add
entries after the
winners list has been displayed.
Hint: Since entries are to be displayed to the screen, grouped by fish
type and in
alphabetical order of angler within a fish-type group, it is suggested
that you maintain
entries in memory (and on disk) in this order. This will facilitate
searching for a
particular angler-fish combination (determining if an entry already
exists) with the use
of the fast binary search algorithm.
will yield the position in which an entry should be inserted,
when a search
for that particular entry has failed.
are required to search for a record identified by a
fish-angler combination.
To do this, develop a function to make a key from the concatenation of
both values. The function can then be used to create a key for the
searched item, and for elements in the array to which it is being
compared.
Option 3: Delete entries
Selection of this option allows the user to delete any number of
existing entries. The
user is required to enter an angler and a fish type to identify an
entry which is to be
deleted. If an entry exists for this angler-fish, it is deleted and
the details of the
deleted entry are displayed. If an entry does not exist, the user is
so advised.
If there are no current entries when this option is selected, or if
there are no entries
remaining after a set of entry deletions, appropriate error messages
should be
displayed. An error message should also be generated if an attempt is
made to delete
entries after the winners list has been displayed.
Option 4: Enter judge's rulings
On the final day of the competition the system maintains a set of
judge's rulings.
Selection of this option allows the user to add more rulings to those
which have
already been entered on that day. The user is firstly prompted for the
number of
rulings to be entered, and then required to enter those rulings, each
represented by a
number in the range 1..7999.
An error message should be generated if an attempt is made to add more
rulings after
the winners list and associated rulings have been displayed.
Hint: Since the total number of rulings that will be entered is not
known (but is likely
to be small), dynamically allocate the storage for ruling numbers.
Option 5: Display the winners
Selection of this option causes the winners list to be displayed,
preceded by the
requisite judge's rulings as shown below:
An example winners list follows:
Since the winners display may exceed one screenful of information ,
the system must
allow the user to view the output, one screenful at a time.
If there are no entries, an appropriate message is displayed.
The following rulings have been applied:
1 Denied Ruling 3345
2 Upheld Ruling 7888
3 Upheld Ruling 6777
For further details apply to the judge.
Press enter to continue
OVERALL WINNER(S)
Motts, Marjorie Catfish 7.000
Largest Barramundi
Brighton, Beach Barramundi 4.000
Pollock, Jackson Barramundi 4.000
Largest Bream
No entries
Largest Whiting
Brighton, Beach Whiting 5.000
Largest Flathead
No entries
Largest PikeyEel
Darwin, Charles PikeyEel 4.000
Earning, Ernst PikeyEel 4.000
Largest Catfish
Motts, Marjorie Catfish 7.000
Largest Shark
No entries
Hint: It is suggested that the entries be sorted into weight order to
determine the
overall and fish-category winners. If this suggestion is adopted, the
following steps
will be required in the execution of this menu option:
if the in-memory entries have been updated (i.e. entries
added/deleted/replaced) and they are in fish-angler order, see if the
user
wishes to update the file, prior to sorting the records into weight
order
(remember the records are to be stored to disk in fish-angler order)
sort the entries by weight
display the judge's rulings (if there are any)
display the winners list
Sorting the entries by weight
A further advantage of storing entries in fish-angler order, is that
when they are
subsequently sorted into weight order using a stable sort algorithm,
entries with
equal weights will remain in their original (fish-angler) order. This
facilitates
determination of multi-way category winners.
However, of the two sorting algorithms presented in the Study Guide,
the inefficient
Bubble Sort is stable and the more efficient Selection Sort is not.
The stable
Insertion Sort algorithm, which is similar in efficiency to the
Selection Sort, is
described below. However, students will not be penalised for using the
less efficient
Bubble Sort in this assignment.
Insertion Sort
In this discussion we will assume that the elements of an integer
array are to be sorted
into descending order.
Like the selection sort, the insertion sort partitions the array into
sorted and unsorted
parts. However, it operates by selecting elements, in turn, from the
unsorted part of
the array and inserting them in the appropriate position in the sorted
part of the array.
In the diagram below, the shaded squares represented the sorted part
of the array and
the unshaded squares represent the unsorted part of the array. With
each iteration, the
next element in the unsorted part of the array, is moved to its
position in the sorted
part of the array.
2 1 3 1 4 5
2 1 3 1 4 5
3 2 1 1 4 5
3 2 1 1 4 5
4 2 2 1 1 5
5 4 3 2 1 1
The insertion sort algorithm is given below, in the form of a C++
function to sort an
array of integers.
Option 6: Save the entries to file
If there are no entries, or if the entries are not in fish-angler
order (i.e. they have been
sorted into weight order), or if no entries have been updated (i.e. no
entries
added/deleted/replaced) appropriate error messages should be
displayed. Otherwise,
the entries stored in memory are updated to the fixed-length binary
file, Entries.dat.
Any entries previously stored in this file will be overwritten.
Option 0: Exit the program
Upon selection of this option, if the in-memory entries have been
updated (i.e. at least
one entry added/deleted/replaced) and if they are in the appropriate
sort order (i.e.
fish-angler order) and their current status hasn't previously been
updated to the file,
the user should be given the option of updating the file prior to
system exit.
********************************************************************************
I need help with pointer,enum,structure etc...
please try to finish it as soon as possible.
thanks, MAULIK. |