I have an annoying problem. We have been given some pseudocode to work with to create a contact detail list, made up of four arrays (one holding first name, one holding last name, one holding phone number and one holding an enrolment number). Separate arrays are used due to us being beginners at Java.
Here is the code we have been given:
Contact detail manager
BEGIN
Input valid user option
WHILE user option not exit
DO
CASE user option OF
1: Initialise contact detail list
2: Display contact details list
3: Insert new entry into contact detail list
4: Delete entry from contact detail list
5: Search contact detail list
END-CASE
Input valid user option
END-WHILE
END
Input valid user option
BEGIN
Display menu;
Input user option
WHILE user option invalid
Display �User option invalid� message
Display menu
Input user option
END-WHILE
END
Initialise contact detail list
BEGIN
Initialise active entry counter to zero
//No need to initialise/reset individual entries
END
Display contact details list
BEGIN
IF contact detail list contains entries
THEN
Display �Contact detail list heading�
FOR each stored contact
DO
Display one/current contact detail
END-FOR
ELSE
Display �Contact detail list empty� message
END-IF
END
Insert new entry into contact detail list
BEGIN
IF contact detail list is not full
THEN
Input enrolment number
Search contact detail list to determine if enrolment number exists
IF enrolment number does not exist
THEN
Input first name
Input last name
Input telephone number
Insert new contact details into contact detail list
Increment active entry count
ELSE
Display �Enrolment number already exists� message
END-IF
ELSE
Display �Contact detail list full� message
END-IF
END
Delete entry from contact detail list
BEGIN
To be designed by student and submitted with final submission
END
Search contact detail list
BEGIN
IF contact detail list contains entries
THEN
Input enrolment number
Search contact detail list to determine if enrolment number exists
IF enrolment number exists
THEN
Display �Contact detail� message
ELSE
Display �Enrolment number unknown� message
END-IF
ELSE
Display �Contact detail list empty� message
END-IF
END
Insert new contact details into contact detail list
BEGIN
IF contact detail list is empty
THEN
Set insertion point of new entry to first entry
ELSE
IF Enrolment number is greater than enrolment number in last entryTHEN
Set insertion point of new entry to entry after current last entry
ELSE
Locate insertion point of new contact detail
Move subsequent existing contact detail entries one position
END-IF
END-IF
Insert new contact detail at insertion point over-writing any previous contact
detail entry
END
Locate insertion point of new contact detail
BEGIN
Set insertion point identifier to first position
WHILE enrolment number to insert is greater than enrolment number stored at
position identified by insertion point identifier
DO
Increment insertion point identifier
END-WHILE
END
I'm having trouble understanding whether I should use an arraylist, like i've been told or an array.
I don't expect other people to do the work for me but i've included the pseudocode just to make things clearer.
Thanks
Here is the code we have been given:
Contact detail manager
BEGIN
Input valid user option
WHILE user option not exit
DO
CASE user option OF
1: Initialise contact detail list
2: Display contact details list
3: Insert new entry into contact detail list
4: Delete entry from contact detail list
5: Search contact detail list
END-CASE
Input valid user option
END-WHILE
END
Input valid user option
BEGIN
Display menu;
Input user option
WHILE user option invalid
Display �User option invalid� message
Display menu
Input user option
END-WHILE
END
Initialise contact detail list
BEGIN
Initialise active entry counter to zero
//No need to initialise/reset individual entries
END
Display contact details list
BEGIN
IF contact detail list contains entries
THEN
Display �Contact detail list heading�
FOR each stored contact
DO
Display one/current contact detail
END-FOR
ELSE
Display �Contact detail list empty� message
END-IF
END
Insert new entry into contact detail list
BEGIN
IF contact detail list is not full
THEN
Input enrolment number
Search contact detail list to determine if enrolment number exists
IF enrolment number does not exist
THEN
Input first name
Input last name
Input telephone number
Insert new contact details into contact detail list
Increment active entry count
ELSE
Display �Enrolment number already exists� message
END-IF
ELSE
Display �Contact detail list full� message
END-IF
END
Delete entry from contact detail list
BEGIN
To be designed by student and submitted with final submission
END
Search contact detail list
BEGIN
IF contact detail list contains entries
THEN
Input enrolment number
Search contact detail list to determine if enrolment number exists
IF enrolment number exists
THEN
Display �Contact detail� message
ELSE
Display �Enrolment number unknown� message
END-IF
ELSE
Display �Contact detail list empty� message
END-IF
END
Insert new contact details into contact detail list
BEGIN
IF contact detail list is empty
THEN
Set insertion point of new entry to first entry
ELSE
IF Enrolment number is greater than enrolment number in last entryTHEN
Set insertion point of new entry to entry after current last entry
ELSE
Locate insertion point of new contact detail
Move subsequent existing contact detail entries one position
END-IF
END-IF
Insert new contact detail at insertion point over-writing any previous contact
detail entry
END
Locate insertion point of new contact detail
BEGIN
Set insertion point identifier to first position
WHILE enrolment number to insert is greater than enrolment number stored at
position identified by insertion point identifier
DO
Increment insertion point identifier
END-WHILE
END
I'm having trouble understanding whether I should use an arraylist, like i've been told or an array.
I don't expect other people to do the work for me but i've included the pseudocode just to make things clearer.
Thanks