The Disappearing Player Assignment

Added on - 18 Oct 2019

  • 6

    pages

  • 1055

    words

  • 127

    views

  • 0

    downloads

Showing pages 1 to 3 of 6 pages
Write an interactive game called The Disappearing Player. The Disappearing Player is a moremagical version of Hangman. In this game, the computer will make up a word, and the user willtry to guess that word before he or she disappears (the player has 8 body parts). The user canguess either a letter or the full word.Ex. of a game:Welcome to The Disappearing Player. What is your name?JoannaO/ |\/ \-The secret word is: __ _ _ _ _ _ _Guess a letter: AA is not in the word. Joanna, you have only 7 body parts remaining.O/ |\/ \The secret word is: __ _ _ _ _ _ _Incorrect guesses: AGuess a letter or word: ZZ is not in the word. Joanna, you have only 6 body parts remaining.O/ |\/ \The secret word is: __ _ _ _ _ _ _Incorrect guesses: AZGuess a letter or word: EE is in the word! Joanna, you still have only 6 body parts remaining.
O/ |\/ \The secret word is: __ _ _ _ _ E _Incorrect guesses: AZGuess a letter or word: RR is in the word! Joanna, you still have only 6 body parts remaining.O/ |\/ \The secret word is: __ _ _ _ _ E RIncorrect guesses: AZGuess a letter or word: SPITTERYour word guess is wrong. Joanna, you have only 5 body parts remaining.O/ |\/The secret word is: __ _ _ _ _ E RIncorrect guesses: AZGuess a letter or word: COMPUTERYour word guess is right! Joanna, you won!Would you like to play again, Joanna? (y or n)NYour record was 1-0. Thank you for playing!If the player loses all the body parts, they lose the game, and should be told the secret word. Theplayer can win by choosing the last letter correctly or by guessing the full word.NOTE: If you want to print a backwards slash, write two of them in a string (and just one will beprinted).System.out.println("/\\"); // this prints: /\NOTE: This is how you create an ArrayList of characters
ArrayList<Character> guesses = new ArrayList<Character> ();// ArrayList must hold an object, not a built in type like chara Character object get be automatically converted to a char, like with:char letter = guesses.get(i); // a Character gets assigned as a charFor this program, you are expected to call and write a number of methods. You will find themethods that you need to write in the shell attached on PowerSchool. Please do not changeanything from the main or from playGame without checking with me first. I want you to usewhat I’ve given you in the way that I gave it to you. When you turn in your code add your nameto the shell’s file name.Extra credit, don't repeat words unless all the words were usedShell that must be usedimport java.util.ArrayList;import java.util.Scanner;public class CPQ6Shell {static Scanner sc = new Scanner(System.in);public static void main(String[] args) {String user = introAndGetUserName();int wins = 0;int losses = 0;String repeatGame="";do {boolean userWins = playGame(user); // returns true if user wins, false otherwise
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Download This Document