Advertisement
SuaveCrouton

Untitled

Apr 8th, 2016
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.88 KB | None | 0 0
  1. For this assignment, you will be building a class, creating objects, doing comparisons and using nested control statements. You need to remember what you have learned in class, lab, books and your assignments. Be sure to refer to them when you need to.
  2.  
  3. There are 2 parts to this assignment. In the first part, you are going to be given a problem and you will then need to create a structure, write algorithms and a flow chart to solve it. In the second part, you’ll be turning this into a java program.
  4.  
  5. So let’s get started!
  6.  
  7. Part 1: Your haunted house adventure!
  8.  
  9. Ever since you were a little kid, there has been this one house at the end of the street that is dark and scary. Everyone says that its haunted! Of course, you don’t believe in those things, but it has inspired you, so you’ve decided to create an interactive haunted house adventure for your friends. Here’s the layout of the house:
  10.  
  11.  
  12.  
  13. The user always starts the game at the front door and must immediately decide where they want to go. Your movement constraints are as follows:
  14. • From the front door, the user must choose between going into the living room, dining room or up the stairs.
  15. • To get from one room to the next, there must be a door. That means that to get to some rooms, the user must go through other rooms. See the above diagram for more details.
  16. • If the user is in a room that is attached to another room via a door (not the one they just came in—no backtracking!), the user must be given the option between going to the other room or exploring an item in the current room.
  17. • If the user is in a room that has no other exit, then they must be given the option between exploring the items in the room.
  18.  
  19. Here are the possible outcomes for exploring items in each room:
  20.  
  21. Floor
  22. Room
  23. Item(s)
  24. Outcome
  25. 1
  26. Living Room
  27. Chest
  28. Ghost escapes and scares you to death
  29. 1
  30. Dining Room
  31. Candelabra
  32. Light up by themselves and see a death shadow
  33. 1
  34. Kitchen
  35. Refrigerator
  36. Open it and find some delicious soul food
  37. 1
  38. Kitchen
  39. Cabinet
  40. The dishes and glasses start flying at you as soon as you open the door. You get hit in the head and feel yourself start moving towards a light
  41. 1
  42. Pantry
  43. Dusty recipe box
  44. You open it up and a recipe for chocolate devils food cake appears our of no where
  45. 1
  46. Pantry
  47. Broom
  48. Flies up in the air as soon as you touch it
  49. 1
  50. Bathroom
  51. Mirror
  52. See a bloody face looking back at you
  53. 1
  54. Bathroom
  55. Shower
  56. Room suddenly steams up and you feel fingers touching the back of your neck
  57. 2
  58. Bedroom 1
  59. Rocking Chair
  60. Chair starts rocking by itself with no one in it
  61. 2
  62. Bedroom 1
  63. Window
  64. See a child outside on a swing who suddenly disappears
  65. 2
  66. Bedroom 2
  67. Doll House
  68. The dolls start dancing on their own
  69. 2
  70. Bedroom 2
  71. Dresser
  72. A ghost flies out of the dresser as soon as you open it and goes right though your body
  73. 2
  74. Master Bedroom
  75. Jewelry Box
  76. You find the cursed Hope Diamond and feel your doom
  77. 2
  78. Master Bathroom
  79. Intricate Oil Lamp
  80. Rub the lamp and a genie pops out who says he’ll grant you 3 wishes
  81. 2
  82. Master Bathroom
  83. Shower
  84. Suddenly hear singing in the shower, but no one is there
  85. 2
  86. Bathroom
  87. Mirror
  88. See a bloody face looking back at you
  89. 2
  90. Bathroom
  91. Shower
  92. Room suddenly steams up and you feel fingers touching the back of your neck
  93.  
  94.  
  95. Program Flow:
  96. • Ask the user to enter their name so that you can personalize their experience. You will want to use their name as they move through the house and make decisions
  97. • Start at the front door as described above.
  98. • Each time the user moves to a new room, you must then ask the user what he or she wants to do next. The options available are derived above. Note that there are sometimes more that 2 options available.
  99. • Should the user reach a room where there is no other exit, they must select an object to explore.
  100. • Once the object is explored, the game is over. This should be indicated clearly to the user (and have fun!).
  101.  
  102. Input/Output Requirements:
  103. • As stated above, you must ask the user for his or her name.
  104. • Welcome the user to the game. Be sure to include their name in your welcome message.
  105. • Using ascii art or graphics, print out an image showing where in the house the user is starting.
  106. • For each step, present the users with their options and ask them what they want to do (hint: put word options in quotes to indicate what they should type in to respond to your question)
  107. • Once they have selected an object to explore, be sure to print out their final outcome.
  108. • At the end of the game, using ascii art or graphics, print out an image showing where in the house the user ended the game.
  109.  
  110. For Part 1, create a class structure, algorithms and flow chart for your program, and then do several iterations of tests (i.e., analyze it and step through to make sure that it is logically correct). Also write the pseudocode for your tester class (where your main will go). Put these in a Word or Open Office document. You’ll turn that document in with the program that you create in Part 2.
  111.  
  112. Important! As you are working on this, be sure to break this down into smaller pieces. Take it step-by-step, and don’t try to finish this in one sitting. It will make it MUST easier.
  113.  
  114.  
  115. Part 2: Creating your Haunted House program
  116.  
  117. Once you are done writing and testing your class structure and algorithm, you are ready to start coding!
  118.  
  119. 1. Once again, you first you need to create a project. Here’s a nice tutorial on how to do that in Netbeans. If you are using Dr. Java or Eclipse, just do a quick search on youtube.com and you’ll find lots of candidates.
  120.  
  121. http://www.youtube.com/watch?v=ezUHG1cuxkM
  122.  
  123. Be sure to give your project a nice, meaningful name (and make sure it adheres to Java’s naming conventions).
  124.  
  125. 2. Once you have your shell ready, there are a few things to know before you start translating your algorithm into code
  126. • At the top of your class file, be sure to include the following:
  127.  
  128. //********************************************************************************
  129. // PANTHERID: [PantherID]
  130. // CLASS: COP 2210 – [Semester Year]
  131. // ASSIGNMENT # [#]
  132. // DATE: [Date]
  133. //
  134. // I hereby swear and affirm that this work is solely my own, and not the work
  135. // or the derivative of the work of someone else.
  136. //********************************************************************************
  137.  
  138. 3. Now start translating your algorithm into java code.
  139. • Remember to code and then compile frequently. It will make it easier to find any bugs.
  140. • Also remember that you will need to create a tester class (where your main method will reside).
  141.  
  142. 4. Once you get your program running correctly, run through 3 scenarios (we will, of course, be testing your other scenarios, but use these for your output):
  143. • Finish in the Living Room
  144. • Finish in the Master Bathroom (choose either option)
  145. • Finish in the Pantry (choose either option)
  146.  
  147. 5. Here is one more thing to do. Any input requested from the user and/or output received from the user should be in a window (see E.1.14 and E.1.15 from lab 1). At this point, you probably have your output going to the console. For your final submission, it needs to go to a window (JOptionPane). Don’t forget any additional libraries that you need to import to do this.
  148.  
  149. That’s it! Now you have written your first adventure game! Of course, you’ll also need to turn it in to Moodle.
  150.  
  151. Submission Requirements
  152. You must upload a zip file to Moodle that includes your complete source project in Netbeans, ready to load (We have been very lenient up until now regarding this. From this assignment on, you will lose points if you do not include your complete project.), and also contains the output in separate data files, and your Word/Open Office document with your algorithm. 
  153.  
  154. VERY IMPORTANT: If you do not provide output in separate, easy to find data files, I will assume that your program does not work on those test cases, and grade accordingly. Do not embed the output in your source code.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement