Here is my advice and some real loose pseudo code:
(1) This past semester I had TWO students with EXACT same first AND last names. It got Real Ugly......
DO NOT compare reservations (or any record types for that matter) by names,locations, etc.
Use the RESERVATION #. Like an account # it is a UNIQUE primary key that DEFINITIVELY identities
the record.
(2) Write a Linear Search routine that identifies if a record with a specific reservation # is in the array
(3) Use TWO arrays.... one is a temporary that allows you to insert/delete records more easily....
Adding new record:
STEP 1: temp array is allocated with N+1.
STEP 2: Then copies current records into temp.
STEP 3: The new record is easily put at the end of the temp array.
STEP 4: Points the current array at temp increments the counter
VIOLA.... done
Deleting records requires TWO for loops....
STEP 1: call your Linear Search routine to verify the target record you want to kill is really in the array, storing the index of its location in the array; otherwise return a nasty negative value and bails out
Step 2: allocates temp with N-1 records.
Step 3: first for loop copies current records into the temp array STOPPING when you hit the target record
you want to kill;
Step 4: the second for loop skips OVER the target record you want to kill and copies the rest of the
current record
Step 5: points current array at temp, decrements the counter
(4) ALWAYS return deep copies of your data. Anyone who walks away with references and addresses to
you data can change it right under your nose , which incidentally undermines OOP principles.
With all of this said, I have uploaded WORKING code in the resources section under the TOOLKIT menu.
The filename is RESERVATION CODE.txt
It is a text file containing THREE (3) java source code classes (hence they must be compiled as three separate source code files)
1) Reservation.java : a simple reservation , which for now only contains the reservation #; that is after
all, only what you need anyway at this point
2) Reservations.java: manages and processes an ARRAY of reservations
3) ReservationBasket.java: main driver
Please take what I have said into serious consideration and THOROUGHLY peruse the code.
Let me know if there is anything you do not understand.
Thanks!