1. This task requires you to modify the INT_LIST class using your answers to Question 1 and 2 from this week's tutorial. Include your answers as part of INT_LIST and then write the following test class to use it.
Use the PERSON class provided and create a simple e-mail address book using a linked list of nodes. This process has been started for you below. What you have to do is write the remaining procedures in class ADDRESS_BOOK below so that this class will read in a person's details and store them in an INT_LIST data structure, find a person's details in such a list, and display the contents of the address book. [Note: The class given here is only a starting point and is neither the only nor the best way of completing this task. You are encouraged to use you own initiative in this task Additionally, there may be bugs in my code, so don't rely on its perfection :)]. This task will give you excellent practice at using linked structures. If you show us a working version of this task (i.e. one that you wrote) you will get an extra homework mark!!!
class ADDRESS_BOOK
creation
make
feature
address_list : INT_LIST[PERSON]
the_person : PERSON
make is
local
quit : BOOLEAN --boolean flag for when you want to exit
--program
do
from
!!address_list.make
until
quit
loop
io.put_string("Dave's Fantastic Address Book%N")
io.put_string("1. Enter a person's details%N")
io.put_string("2. Find a person in the list (by name)%N")
io.put_string("3. Display the whole list%N")
io.put_string("Any other number to quit%N")
io.put_string("Enter choice: ")
io.read_integer
inspect io.last_integer
when 1 then
get_details
add_to_list
when 2 then
find_the_person
when 3 then
display_the_list
else
io.put_string("%NSee ya later")
quit := True
end --inspect
end --make
get_details is
local
the_name, the_email : STRING
do
io.new_line
io.put_string("Please enter the person's name: ")
io.read_line
the_name := io.last_line
io.put_string("Please enter the person's e-mail address: ")
io.read_line
the_email := io.last_line
!!the_person.make(the_name, the_email)
end --get_details
add_to_list is
--adds the_person to the list
do
--write code here
end --add_to_list
find_the_person is
--asks for the name of the person to find and then
--displays the details if the person exists in the list,
--other wise it tells the user the person is not there.
do
--write code here
end --find_the_person
display_the_list is
--displays all of the names and e-mail addresses in the list
--Uses the display_person feature of the PERSON class
do
--write code here
end --display_the_list
end --ADDRESS_BOOK