Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Address book
- This will be a command line program for managing and searching contacts in an address book.
- ## How to run Ruby code
- 1) Write Ruby code in a file `<filename>.rb`
- 2) On command line, run
- ```shell
- ruby <filename>.rb
- ```
- ## Requirements
- ### Program flow
- The program will print
- ```shell
- Select an action: list | search | create | edit <ID> | delete <ID>
- ```
- when it starts up, and after every executed action.
- For almost all actions, it's going to ask and get user inputs like this,
- ```shell
- (PRINT) Select an action: list | search | create | edit <ID> | delete <ID>
- (GET INPUT) delete 1
- (PRINT) Are you sure to delete this contact? (Yes/No)
- (GET INPUT) Yes
- (PRINT) The contact has been deleted.
- ```
- ### Create a contact
- I should be able to create a contact and store it. Contact attributes are:
- - First name
- - Last name
- - Phone number
- - Email
- ```shell
- Select an action: list | search | create | edit <ID> | delete <ID>
- create
- Please fill out the contact attributes.
- First name:
- John
- Last name:
- Smith
- Phone number:
- 000-000-0000
- Email:
- fake@email.com
- The contact has been created.
- ```
- ### List contacts
- I should be able to list all the contacts with their IDs (i.e. ordinal numbers).
- ```shell
- Select an action: list | search | create | edit <ID> | delete <ID>
- list
- 1, John Smith, 000-000-0000, fake@email.com
- 2, Linda Vasquez, 111-111-111, fake2@email.com
- ```
- If the list is empty,
- ```shell
- Select an action: list | search | create | edit <ID> | delete <ID>
- list
- The list is empty.
- ```
- ### Edit a contact
- I should be able to edit an existing contact's attributes by its ID.
- ```shell
- Select an action: list | search | create | edit <ID> | delete <ID>
- edit 1
- Please fill out the contact attributes.
- First name:
- John
- Last name:
- Anderson
- Phone number:
- 222-222-2222
- Email:
- fake@email.com
- The contact has been updated.
- ```
- If a contact doesn't exist with the given ID,
- ```shell
- Select an action: list | search | create | edit <ID> | delete <ID>
- edit 5
- Contact not found.
- ```
- ### Delete a contact
- I should be able to delete a contact by its ID.
- ```shell
- Select an action: list | search | create | edit <ID> | delete <ID>
- delete 1
- Are you sure to delete this contact? (Yes/No)
- Yes
- The contact has been deleted.
- ```
- ```shell
- Select an action: list | search | create | edit <ID> | delete <ID>
- delete 1
- Are you sure to delete this contact? (Yes/No)
- No
- ```
- If a contact doesn't exist with the given ID,
- ```shell
- Select an action: list | search | create | edit <ID> | delete <ID>
- delete 5
- Contact not found.
- ```
- After deletion, the IDs of the contacts following the deleted contact should be adjusted.
- ```shell
- Select an action: list | search | create | edit <ID> | delete <ID>
- list
- 1, John Smith, 000-000-0000, fake@email.com
- 2, Linda Vasquez, 111-111-111, fake2@email.com
- Select an action: list | search | create | edit <ID> | delete <ID>
- delete 1
- Are you sure to delete this contact? (Yes/No)
- Yes
- The contact has been deleted.
- Select an action: list | search | create | edit <ID> | delete <ID>
- list
- 1, Linda Vasquez, 111-111-111, fake2@email.com
- ```
- ### Search contacts
- I should be able to search contacts by first name and last name.
- ```shell
- Select an action: list | search | create | edit <ID> | delete <ID>
- search
- First name:
- John
- Last name:
- 1, John Smith, 000-000-0000, fake@email.com
- 4, John Anderson, 111-111-1111, fake2@email.com
- 19, John Underwood, 222-222-2222, fake3@email.com
- ```
- ```shell
- Select an action: list | search | create | edit <ID> | delete <ID>
- search
- First name:
- John
- Last name:
- Underwood
- 19, John Underwood, 222-222-2222, fake3@email.com
- ```
- ```shell
- Select an action: list | search | create | edit <ID> | delete <ID>
- search
- First name:
- Last name:
- Underwood
- 17, Alex Underwood, 444-444-4444, fake4@email.com
- 19, John Underwood, 222-222-2222, fake3@email.com
- ```
- ```shell
- Select an action: list | search | create | edit <ID> | delete <ID>
- search
- First name:
- Last name:
- No results found.
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement