Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVA One-Player Games As with all labs, this is graded and is completed with a partner. Only one of you need to submit for

image text in transcribedimage text in transcribed

IN JAVA

One-Player Games As with all labs, this is graded and is completed with a partner. Only one of you need to submit for the group. You must be in class to complete this lab and receive a grade There are many types of interactive, one-player games. These include games like hangman and nonogram. Be sure to check each one out if you are not familiar with them before proceeding. There are certain common elements of each game mentioned above such as allowing the user to make a move, and telling the user if they have won the game. However, each game also has its own set of rules, and the screen or board could look very different. In this lab, you will create an interface, Game, and implemented by two classes: (1) Nonogram, and (2) Hangman. First, think about what instance data need to be stored in each class as this is very important before you proceed. Each game has a hidden solution and the current attempt which records the moves made by the player. Then, complete the lab adhering to the following guidelines: Use the code for the main class provided her Read this code carefully as it gives you hints on how to design and code the rest. Define an interface called Game containing method headers for getEntry() and game Over() Define two classes, Hangman and Nonogram, which implement the interface. getEntry() asks the user to make one move in the game and records this. It should also print the current attempt at the solution. gameOver() checks whether the user has guessed the solution and completed the game. Note that to compare two strings, you must use the equals method, to compare to arrays to see if they contain the same elements, you must compare each pair of elements (one from each array). Provide at least one constructor and toString() methods in all classes. Examine the constructor calls in the main method provided so you can infer how your constructors should work. public static void main(String[] args) { //test the Hangman class System.out.println("Playing Hangman:"); Hangman game1 = new Hangman ("UHART"); while (!game1.gameOver() //while the game is not over, keep playing game1.getEntry(); System.out.println(game1 + "\tYou won!"); //test the Nonogram class using a small 2x2 array System.out.println("Playing Nonogram:"); Nonogram game2 = new Nonogram (new int[][] {{0,1},{1,0}}); while (!game2.gameOver() /while the game is not over, keep playing game2.getEntry(); System.out.println(game2 + "You won!"); }

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_2

Step: 3

blur-text-image_3

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 Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

What is a financial feasibility analysis?

Answered: 1 week ago