Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I need help with a homework assignment for computer science. This is for java. I have to make a game where a player needs

Hello, I need help with a homework assignment for computer science. 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 specific things that the program needs:

  • It should have 15 movie names to randomly choose from.
  • There should be a way so that if someone enters something like asdfdfsdg, it accepts the first letter which is a, the program shouldn't crash.
  • 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.
  • The user can have 7 wrong guesses before the game is over.
  • If the user gets all of it wrong with the 7 tries it should also display the name of the movie that they couldn't guess and it should say that they don't have any tries left.
  • If the user guesses all the letters, they win. It should display that they won and it should also display the movie that they got correct.

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

Students also viewed these Databases questions

Question

Identify three types of physicians and their roles in health care.

Answered: 1 week ago

Question

Compare the types of managed care organizations (MCOs).

Answered: 1 week ago