Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is for java. I have to make a game where a player needs to guess a movie. The program will randomly select a movie

This is for java. I have to make a game where a player needs to guess a movie. The program will randomly select a movie title and display a shadow of the movie name using asterisks. If the movie is "Star Wars", the program will show **** **** at the beginning of the game. The user then tries to guess the movie title by entering one letter at a time. If the user tries 'A' or 'a', the next display shall be: **a* *a** However, the user is only allowed 7 mistakes. Once the user guesses all the letters in the phrase, that person wins.

These are some specifications that the program needs:

  • I should have 15 movie names to randomly choose from.
  • There should be a way so that if someone enters something like 632453454325, it only gets the first integer which is 6.
  • Use Stringbuilder class. You can find information about this class using the Java API
    • This class allows you to modify Strings (i.e. get and change a character in the string)
  • Phrases are allowed to use upper and lowercase letters
  • If the movie title uses characters other than a letter, please reveal that character. Do not use an asterisk.
    • use the Character.isLetter method - Starter code shows how to use this.
    • Example:
      • For the movie "Star Wars: The Last Jedi"
      • The game starts with: **** ****: *** **** ****
      • Notice how the colon character is displayed above.
  • User can have 7 wrong guesses before the game is over.
  • If the user guesses all the letters, they win.

I also have some starter code as well:

import java.util.*; import java.lang.*;

public class Hangman { //This is an array of Strings static String movieList[] = {"Star Wars: The Last Jedi","The Matrix","Avatar"}; // add more to this list by adding more String Literals separated by commas /** * Entry point of the program * @param args input arguments */ public static void main(String[] args) { String movie = movieList[0]; // picks the Star Wars movie for the game StringBuilder currentGuess = new StringBuilder(movie.length()); System.out.println(movie);

char c = movie.charAt(0); if(Character.isLetter(c)) System.out.println(c + " is a letter"); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The New Profit Frontier

Authors: Ed Burnett

1st Edition

0964535629, 978-0964535626

More Books

Students also viewed these Databases questions

Question

What advice would you provide to Jennifer?

Answered: 1 week ago

Question

What are the issues of concern for each of the affected parties?

Answered: 1 week ago