Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. In this game, a player is asked by computer to type in several animal names such as "dog," "cat," etc., in the beginning of the game session. There is no limit to the count of the names but these names must be space delimited. When entering a return key without typing anything (i.e., empty line), this process of input cycle ends. So, use getline()discussed in recent lecture to realize this input logic. Then you should break up the line of input being isolating "words". A word can be defined as a sequence of consecutive non-white-space characters with white space before and after.
  2.  
  3. Do not use anything from stringstream. For this assignment you should use functionality from <vector> and <string> including getline(istream&, string&) and from <algorithm> rand_shuffle function.
  4.  
  5. The computer will pick up 1 to 3 names from those entered by the player. They are shuffled to produce a random word. The player will be asked to identify the names, given a hint of how many animals in that word. The player needs to type in names (or a name if asked one). Typing "?" will show the name list, and typing "quit" will end the game.
  6.  
  7. When succeeding to answer in two consecutive rounds, the computer's challenge becomes harder by striking out a character one by one. The position to strike out is chosen at random. So, succeeding 4 consecutive times, the random word has two strikes out shown by underscore "_" characters. On the other hand, failing to answer in two consecutive rounds, the computer's challenge becomes easier by reducing the count of strikes out. The sample session follows.
  8.  
  9. Enter at least five animal names, e.g., cat, dog, etc...
  10. > dog cat
  11. > snake zebra
  12. > tiger
  13. >
  14. 1: dog
  15. 2: cat
  16. 3: snake
  17. 4: zebra
  18. 5: tiger
  19.  
  20. What are 2 animals in "gbzeoard" ? zebra dog
  21. Yes!
  22.  
  23. What are 2 animals in "dgaoct" ? dog cat
  24. Yes!
  25. Succeeded two consecutive times, challenge goes up!
  26.  
  27. What are 1 animal in "ezar_" ? zebra
  28. Yes!
  29.  
  30. What are 1 animal in "do_" ? dog
  31. Yes!
  32. Succeeded two consecutive times, challenge goes up!
  33.  
  34. What are 1 animal in "z__ae" ? zebra
  35. Yes!
  36.  
  37. What are 2 animals in "okadg__n" ? dog snake
  38. Yes!
  39. Succeeded two consecutive times, challenge goes up!
  40.  
  41. What are 1 animal in "_ke__" ? snake
  42. Yes!
  43.  
  44. What are 2 animals in "e_d_g_ir" ? tiger dog
  45. Yes!
  46. Succeeded two consecutive times, challenge goes up!
  47.  
  48. What are 3 animals in "et_s__era_ngk" ? cat zebra snake
  49. Nope!
  50.  
  51. What are 1 animal in "__i__" ? dog snake
  52. Your number of input is incorrect. Enter again: dog
  53. Nope!
  54. Missed two consecutive times, challenge goes down!
  55.  
  56. What are 1 animal in "___" ? cat
  57. Yes!
  58.  
  59. What are 3 animals in "koge__zsaa_db" ? ?
  60. 1: dog
  61. 2: cat
  62. 3: snake
  63. 4: zebra
  64. 5: tiger
  65. Your number of input is incorrect. Enter again: quit
  66. Bye...
  67.  
  68. This assignment will ask you to use <string>, string::getline(), <vector> and random_shuffle() or shuffle() from <algorithm> to reduce the amount of coding. You can find many examples on the Web -- see here for instance.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement