Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. # Address book
  2.  
  3. This will be a command line program for managing and searching contacts in an address book.
  4.  
  5. ## How to run Ruby code
  6.  
  7. 1) Write Ruby code in a file `<filename>.rb`
  8.  
  9. 2) On command line, run
  10.  
  11. ```shell
  12. ruby <filename>.rb
  13. ```
  14.  
  15. ## Requirements
  16.  
  17. ### Program flow
  18.  
  19. The program will print
  20.  
  21. ```shell
  22. Select an action: list | search | create | edit <ID> | delete <ID>
  23. ```
  24.  
  25. when it starts up, and after every executed action.
  26.  
  27. For almost all actions, it's going to ask and get user inputs like this,
  28.  
  29. ```shell
  30. (PRINT) Select an action: list | search | create | edit <ID> | delete <ID>
  31. (GET INPUT) delete 1
  32. (PRINT) Are you sure to delete this contact? (Yes/No)
  33. (GET INPUT) Yes
  34. (PRINT) The contact has been deleted.
  35. ```
  36.  
  37. ### Create a contact
  38.  
  39. I should be able to create a contact and store it. Contact attributes are:
  40.  
  41. - First name
  42. - Last name
  43. - Phone number
  44. - Email
  45.  
  46. ```shell
  47. Select an action: list | search | create | edit <ID> | delete <ID>
  48. create
  49. Please fill out the contact attributes.
  50. First name:
  51. John
  52. Last name:
  53. Smith
  54. Phone number:
  55. 000-000-0000
  56. Email:
  57. fake@email.com
  58. The contact has been created.
  59. ```
  60.  
  61. ### List contacts
  62.  
  63. I should be able to list all the contacts with their IDs (i.e. ordinal numbers).
  64.  
  65. ```shell
  66. Select an action: list | search | create | edit <ID> | delete <ID>
  67. list
  68. 1, John Smith, 000-000-0000, fake@email.com
  69. 2, Linda Vasquez, 111-111-111, fake2@email.com
  70. ```
  71.  
  72. If the list is empty,
  73.  
  74. ```shell
  75. Select an action: list | search | create | edit <ID> | delete <ID>
  76. list
  77. The list is empty.
  78. ```
  79.  
  80. ### Edit a contact
  81.  
  82. I should be able to edit an existing contact's attributes by its ID.
  83.  
  84. ```shell
  85. Select an action: list | search | create | edit <ID> | delete <ID>
  86. edit 1
  87. Please fill out the contact attributes.
  88. First name:
  89. John
  90. Last name:
  91. Anderson
  92. Phone number:
  93. 222-222-2222
  94. Email:
  95. fake@email.com
  96. The contact has been updated.
  97. ```
  98.  
  99. If a contact doesn't exist with the given ID,
  100.  
  101. ```shell
  102. Select an action: list | search | create | edit <ID> | delete <ID>
  103. edit 5
  104. Contact not found.
  105. ```
  106.  
  107. ### Delete a contact
  108.  
  109. I should be able to delete a contact by its ID.
  110.  
  111. ```shell
  112. Select an action: list | search | create | edit <ID> | delete <ID>
  113. delete 1
  114. Are you sure to delete this contact? (Yes/No)
  115. Yes
  116. The contact has been deleted.
  117. ```
  118.  
  119. ```shell
  120. Select an action: list | search | create | edit <ID> | delete <ID>
  121. delete 1
  122. Are you sure to delete this contact? (Yes/No)
  123. No
  124. ```
  125.  
  126. If a contact doesn't exist with the given ID,
  127.  
  128. ```shell
  129. Select an action: list | search | create | edit <ID> | delete <ID>
  130. delete 5
  131. Contact not found.
  132. ```
  133.  
  134. After deletion, the IDs of the contacts following the deleted contact should be adjusted.
  135.  
  136. ```shell
  137. Select an action: list | search | create | edit <ID> | delete <ID>
  138. list
  139. 1, John Smith, 000-000-0000, fake@email.com
  140. 2, Linda Vasquez, 111-111-111, fake2@email.com
  141. Select an action: list | search | create | edit <ID> | delete <ID>
  142. delete 1
  143. Are you sure to delete this contact? (Yes/No)
  144. Yes
  145. The contact has been deleted.
  146. Select an action: list | search | create | edit <ID> | delete <ID>
  147. list
  148. 1, Linda Vasquez, 111-111-111, fake2@email.com
  149. ```
  150.  
  151. ### Search contacts
  152.  
  153. I should be able to search contacts by first name and last name.
  154.  
  155. ```shell
  156. Select an action: list | search | create | edit <ID> | delete <ID>
  157. search
  158. First name:
  159. John
  160. Last name:
  161.  
  162. 1, John Smith, 000-000-0000, fake@email.com
  163. 4, John Anderson, 111-111-1111, fake2@email.com
  164. 19, John Underwood, 222-222-2222, fake3@email.com
  165. ```
  166.  
  167. ```shell
  168. Select an action: list | search | create | edit <ID> | delete <ID>
  169. search
  170. First name:
  171. John
  172. Last name:
  173. Underwood
  174. 19, John Underwood, 222-222-2222, fake3@email.com
  175. ```
  176.  
  177. ```shell
  178. Select an action: list | search | create | edit <ID> | delete <ID>
  179. search
  180. First name:
  181.  
  182. Last name:
  183. Underwood
  184. 17, Alex Underwood, 444-444-4444, fake4@email.com
  185. 19, John Underwood, 222-222-2222, fake3@email.com
  186. ```
  187.  
  188. ```shell
  189. Select an action: list | search | create | edit <ID> | delete <ID>
  190. search
  191. First name:
  192.  
  193. Last name:
  194.  
  195. No results found.
  196. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement