A
Aaron Haas
I=E2=80=99m trying to create a simple address book in ruby. It is made u=
p from
the following classes. Address, Phone, Person, and AddressBook . The
Address, Phone, Person classes all work fine. I=E2=80=99m having problem=
s with
several methods in my AddressBook class.
Add(person) needs to check if that person already exists. I tried using
my query method but it only prints the name to the screen. Can I make
it also return an person object to use as a comparison?
The prompt method should take a command (add, print, remove, find,
exit) then depending on which command ask the user for required
information. The command prompts should run continuously until =E2=80=9C=
exit=E2=80=9D
is entered. The add command which is the most complicated of the five
works fine for a single time. I can=E2=80=99t figure out how to implemen=
t a
while condition to keep it going without getting errors.
I=E2=80=99m also having problems with the remove method logic. I built t=
he
remove method to take a variable name as a parameter, but the command
prompt would require an first and last name instance fields from the
person class.
I'm getting close just a few tweaks here and there.
This code is getting long one so I just attached the file. If you think
I should copy and paste let me know.
Attachments:
http://www.ruby-forum.com/attachment/5368/Ruby_AB.rb
-- =
Posted via http://www.ruby-forum.com/.=
p from
the following classes. Address, Phone, Person, and AddressBook . The
Address, Phone, Person classes all work fine. I=E2=80=99m having problem=
s with
several methods in my AddressBook class.
Add(person) needs to check if that person already exists. I tried using
my query method but it only prints the name to the screen. Can I make
it also return an person object to use as a comparison?
The prompt method should take a command (add, print, remove, find,
exit) then depending on which command ask the user for required
information. The command prompts should run continuously until =E2=80=9C=
exit=E2=80=9D
is entered. The add command which is the most complicated of the five
works fine for a single time. I can=E2=80=99t figure out how to implemen=
t a
while condition to keep it going without getting errors.
I=E2=80=99m also having problems with the remove method logic. I built t=
he
remove method to take a variable name as a parameter, but the command
prompt would require an first and last name instance fields from the
person class.
I'm getting close just a few tweaks here and there.
This code is getting long one so I just attached the file. If you think
I should copy and paste let me know.
Attachments:
http://www.ruby-forum.com/attachment/5368/Ruby_AB.rb
-- =
Posted via http://www.ruby-forum.com/.=