Design And Implement Word Guessing Game

Dec 29, 2013

I have a project about programing a game in java . In this project you are required to design and implement a word guessing game. In the game, user selects one of the available dictionaries (animals, plants, technical, names, etc. ), and the program randomly chooses one word from that dictionary and displays it by scrambling the letters. The user tries to guess the word while a guess counter starts to count down (lets assume it starts from 5).

While counter counts towards zero, the program chooses -randomly- two misplaced letters and puts them into correct positions to reveal the word more and give the user a hint. However, giving a new hint reduces the total value of the question. Lets say if the initial value of the question is 500 when all letters are scrambled, it reduces to 400 after 1st incorrect guess and hint, then after every incorrect guess it reduces more. You can determine the value of the question by the length of the word. The other details of the game is as follows:

1.You must design at least three classes (for example game, scrambledword, and dictionary).

2.Dictionaries are written in text files. If you design a class for dictionary, it must be constructed by a user chosen category ((animals, plants, technical, names, etc). In the constructor, the dictionary text file corresponding to this category must be opened and read; and words in that dictionary must be read into memory (e.g. String array). You must submit your dictionaries with your code. Do not share dictionaries between friends.

3.The game will record your total points and name in a text file where a hall of fame which has different users and their total points in 10 questions. You can design and implement a class for this.

4.Bonus+5%: Put user interface modules textboxes, buttons, etc Or

a.Use class hierarchy

b.Use of thread and timers and reducing the question value by timer instead of guesses.

View Replies


ADVERTISEMENT

Guessing Game Program

Feb 10, 2015

I'm in an introduction CSE class and we're working with Java. Basically I need to create a program using scanner, while loops, and pseudorandom numbers. My program is a guessing game and I will post below the code that I already have. Basically I can get the game to work and get it to ask if you want to play another game and it keeps going until you say no. But my issue is getting the statistics of the game down. I need a separate method not in main to produce this at the end of the game once the user decides to stop playing:

Overall results:
total games = int
total guesses = int
guesses/games = double
best game = int

here's my code:

import java.util.*;
public class Guess {
public static void main(String[] args) {
intro(100);
Scanner console = new Scanner(System.in);
game(console, 100);
int numGuesses = 0;
int numGames = 1;
int end = 0;

[code]....

View Replies View Related

Guessing Game - How To Reset Random Number When User Reset Game

Oct 2, 2014

I tried this program, its guessing game. Where program decide 1 number and user will guess number. I am getting 1 problem. When user want to play game again.the random number remain same. So where i can put reset random in code..? And 1 more question if I want to write driver code for this. What should i transfer to driver code.

import java.util.Random;
import java.util.Scanner;
public class GuessGame {
public static void main(String args[])
{
String choice="y";

[Code] ......

View Replies View Related

Guessing Game Always Choose Same Number

Jan 4, 2015

I am using eclipse for this project. Every time I run this program the choose method will always choose 0. Ignore the Sleep.sleep() method, there is another class in the program that performs it.

import java.util.Scanner;
public class gamestart {
public static int num;
public static String name;
public static String diff;
public static String choice;

[Code] ....

View Replies View Related

Guessing Game - Won't Add Buttons To Frame

Aug 6, 2014

I have a guessing game that im working on but it wont add my buttons to the frame, why?

// GuessGame.java
// Guess the number
import javax.swing.JFrame;
public class GuessGame extends JFrame {
public static void main(String args[]) {
GuessGame panel = new GuessGame();
panel.setSize(400,350);

[Code] ...

The window pull up and even in the design view it shows everything on there but when i run its just a blank window.

View Replies View Related

Develop A Guessing Game Application

Nov 6, 2014

Here is my instangable class

The application should generate a random number between 1 and 10 and then ask the user to enter one single number between 1 and 10 to guess what the secret number is

public class Guess{

//Variables
private int Num;
private int rNo;
private String message;
//Constructors
public Guess(){
rNo = 0;
message = "";

[Code] .....

Two errors are

Guess.java:43: error: illegal start of expression
public String getMessage(){

uess.java:43: error: ';' expected
public String getMessage(){

View Replies View Related

Creating A Guessing Game In Java

Nov 30, 2014

I am creating a Guessing game program in java code. I am having an issue with the guess class and main/tester class running. The instructions for the game are The computer generates a random # and the user must guess that number in 7 or fewer guesses. If the guesses exceed 7, then the game is over and the user is asked if they want to 'play again?'These are things I need to incorporate into my code:

If Statement

A Loop of some kind
At least three imported methods
At least two methods you create
Obtains input from the user
At least two instance variables
At least two local variables
Some form of concatenation
At least two calculations

import java.util.Random;
public class Guess
{
int computersNumber; // A random number picked by the computer.
int usersGuess = 0; // A number entered by user as a guess.
int guessCount = 0; // Number of guesses the user has made.

[code]...

View Replies View Related

Design And Implement Application That Produces Multiplication Table

Feb 28, 2014

Design and implement an application that produces a multiplication table, showing the results of multiplying the integers 1 through 12 by themselves

View Replies View Related

Design And Implement GUI Front End For Computerized Version Of Battleship

Feb 21, 2014

Code for implementing a simple computerised version of Battleships has been supplied. Examine the code ensuring that you understand it. The game is played against the computer.

A number of ships (default is 6) are place randomly on a 4 x 4 grid. A ship occupies one square only. The player then guesses the position of a ship. If he/she guesses correctly the ship is HIT and sinks. If the guess is incorrect the player loses a life. The default number of lives is 7. If the location has been guessed already, no lives are lost.

When the game starts, a 4 x 4 grid should be displayed.

The user should be allowed to enter/select a cell location. If the selected cell contains a ship, the ship will be destroyed. If not the player loses a life. The cell should display an appropriate picture, icon or message informing the user of its current state.

The number of lives and number of ships remaining should be displayed.

When the game ends an appropriate message should be shown informing the player whether he/she has won or lost. The positions of the ships should also be shown.

The purpose of this assignment is that students demonstrate an understanding of the Java Swing library and that he/she can navigate and use the API effectively.

Your finished GUI should be both user-friendly and aesthetically pleasing.

Ideally, the user should have the option to play another game, to quit or give up mid-game. You may also wish to include other options such as different levels of difficulty, etc.

View Replies View Related

Tracking Number Of Games Within Guessing Game

Aug 22, 2014

/*
/ GuessGame.java
*/

import java.util.Scanner;
import java.util.Random;
public class GuessGame {
public static void main(String[] args) {

[code]....

tracking the number of games played, and also when running the code, I have to press "1" twice for it to actually load up the game again.

View Replies View Related

Broken Loop - Number Guessing Game

Jun 3, 2014

What's wrong with my code. It says 'you win' even when I guess an incorrect number. And then the 'win' message keeps repeating. I'm thinking I need a way to generate a new input? And then maybe take the 'win' message out of the loop, but that breaks it too.

View Replies View Related

Random Number Guessing Game With Three Tries (Loops)

Mar 8, 2014

I was told to write a program which generates a random number between 0 to 5 *including 5* and give the user 3 chances to guess this number:

-If the user enters a wrong number within 0 to 5, the user has lost one opportunity.
-If the user enters a number out of range, the program should prompt the user to enter a number within the range
-If the user has 3 unsuccessful attempts, the program will print the number.

I was also instructed to use :

Random randomNumber=new Random();
int i= randomNumber.nextInt(6)

I have attempted it and this is what i have so far.
 
import java.util.Random;
import java.util.Scanner;
public class Exercise1
{
public static void main(String[] args)
{
Random randomNumber=new Random();

[Code] .....

View Replies View Related

Guessing Game Demo - How To Add DoAgain Loop

Apr 8, 2014

Ok, here's what I got.
 
import java.util.Random;
import java.util.Scanner;
 
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
 
public class demoGuessGame { 
public static void main(String[] args) {
Random any = new Random();
Scanner input = new Scanner (System.in);
try {
  int maxNum, maxTries, guess;
boolean win = false;
 
[Code] .....

I want to make it loop again when asked, "Do you want to play again?"

View Replies View Related

Lottery Game - Number Guessing Program

Sep 6, 2014

I wrote the following code for a lottery game. The problem comes when I run it. If one number of a 3 digit number matches, it's supposed to print "you win 1000" But regardless if a number matches or not, it says "sorry, no matches" ...

import java.util.Scanner;
public class Lottery {
public static void main(String[] args){
//generate lottery number
int lottery = (int)(Math.random() * 1000);
//Prompt the user to enter numbers
Scanner input = new Scanner (System.in);
System.out.print("Enter your numbers (3 digits): ");
int guess = input.nextInt();

[Code] .....

View Replies View Related

Word Game (how To Check That Word Is In Dictionary)

Apr 21, 2014

import java.io.*;
import java.util.Random;
import java.util.Scanner; 
public class WordGame
{
public static void main(String[] args) throws IOException
{
final int RANDOM_LETTERS_COUNT = 10;
final int TRIALS = 10;
int score = 0;

[Code] ....

View Replies View Related

JSP / JSTL :: What Is The Difference Between Design Patterns And Frame Word

Feb 20, 2006

what are design patterns ? what is the difference between design patterns and frameword ?

View Replies View Related

Guessing Game (numbers Between 1 And 100) - Getting Results To Give Correct Int

Feb 10, 2015

I've been working on a program where you can interact with the computer and play a guessing game of numbers between 1 and 100. It's mainly finished, I just need to add in my comments and stuff. My one problem about it that I cannot figure out is trying to get the results to give the correct int. At the end of the game, it's supposed to return the user information about how well they did like this:

Overall results:
total games = int
total guesses = int
guesses/game = double
best game = int

best game should give you the least amount of guesses you had during a particular round of the game. Here is what I have so far:

import java.util.*;
public class Guess {
public static final int MAX = 100;
public static void main(String[] args) {
intro(MAX);
Scanner console = new Scanner(System.in);
int tempBestGame = 0;

[Code] .....

View Replies View Related

Design And Develop Program To Implement Lazy Buddy System Algorithm

Jul 19, 2014

I want to know the java code for lazy buddy system algorithm which can be run in eclipse or netbeans

View Replies View Related

Guessing Game GUI - Comparing Guess With Randomly Generated Number

Apr 13, 2014

package guess.the.numbers;
import java.awt.*;
import javax.swing.*;
import java.util.Random;
import java.awt.event.*;
ublic class GuessTheNumbers extends JFrame{
private JButton guessBtn;
private JButton restartBtn;

[Code] ....

I am getting a strange error and it almost seems like its not comparing it to the random generated number just the guess that i entered before. Here are my error messages.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at guess.the.numbers.GuessTheNumbers$ButtonHandler.actionPerformed(GuessTheNumbers.java:119)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)

[Code] .....

View Replies View Related

Design Open Answer Quiz Game

Oct 31, 2014

I want to design an open-answer quiz game using Java. Basically, the plan is to design a quiz where the name of a medicine is displayed as "the question" and the player will need to input the unique code (as "the answer") of the medicine in an open box (all the codes are two characters). The list has about 204 named medicine (with potentially more to be included at a later stage). The questions will not appear in the same order for each session restarted; they will appear randomly.

The player will have 60 seconds, and for each correct answer, will score 1 point and add 2 seconds to the timer. The player will also have 6 "lives", and for each incorrect answer, the player will lose a life, with no effect on the time.The idea of the game is to support the player memorise as many of these medicine codes as possible. How this can be achieved from total grassroots.

View Replies View Related

Design Class - How To Organize Classes For UNO Card Game

Mar 20, 2014

I'm currently taking a computer program design class which has done a lot for my understanding of how to organize classes, but isn't giving me challenging enough assignments and I don't believe it's going to be covering interfaces and abstract classes, which is a shame. So I've been digging into these topics myself and decided to work on my own program (an Uno game program) that would utilize everything we've been learning and give me some practice with GUIs.

My current plan:

Have an abstract UnoCard class that determines the basic properties/methods common to all cards. Create a class for each card type extending from UnoCard, which would be - the generic card (number and color), action cards (skip, reverse, draw two), and special cards (wild, wild draw four, and blank).

Two enums, one for color, one for rank (which includes the numbers, as well as the action and special card ranks (reverse, wild, exc.) ).

A deck class would have an ArrayList <UnoCard> property and it's constructor would initialize a fresh deck.

A hand class that also has an ArrayList <UnoCards> where it gets said cards from the deck class.

A discard pile class, which contains the cards discarded and the current card in play.

A "board" class (haven't figured out a better name for it yet) which would determine/keep track of the number of players/hands, the turn order, the locations of the cards, and the winning condition.

Area of confusion and concern I'm having:

From what I've read, I want to avoid circular dependency. So if that's the case, when a card type effects the state of a "hand" or the turn order or really anything else, then in what class do I place the method(s) that effect that? If I place it in the specific card class, wouldn't that create a circular dependency? So would it be better then to have the hand class figure out what can be done with a specific card and what that specific card effects (which wouldn't that hinder the cohesion of the class?)?

I was also thinking a possible solution might be to have the non-generic card types contain methods that return values as apposed to manipulating higher level classes, such as a boolean drawCards which returns true if cards need to be drawn, false otherwise (same for skip, reverse, exc.).Then maybe the board class can determine what to do if those values are true or false (which actually seems more convoluted since only one value would be allowed to be true at any given time).

The other solution I was considering is to have a single UnoCardRules class, which serves the sole function of providing methods to determine the effects of each card, that way each card class can only worry about defining the card's state.

View Replies View Related

How To Implement Basic Text-based Rpg Game In A Website

Jan 13, 2015

I started programming some time ago and i recently finished a game i've been programming in Java just to get used to the code. The game is a simple text-based RPG where almost everything is random except the character movement.

I've been thinking about learning HTML and CSS because i'm really interested in building webpages. I have no one to ask this question so here i am.

Is there a way to implement my game in a webpage?

I imagine a black window exactly like a classic OS terminal where the text is streamed and the user can play the game with keyboard inputs. I made the game with 5 different classes, i used Eclipse and i have my project there. Should i use a service like Github to share works like this one?

View Replies View Related

Create Word Game Using Classes And Objects

Feb 14, 2015

For class, we need to create a word game using classes and objects.

The game is played in rounds. The player is presented with a word that is missing letters. The player has to fill in the missing spaces with their letter guesses. The words presented are chosen with a random number generator which has been provided for us. At the end of the game, the player is shown their score.

In steps, I have to:

-Welcome the player.
-Present the puzzle.
-Allow the player to fill in the blanks.
-Have the program check responses for correct/incorrect input.
-End the game if they have three misses, or continue if they complete the puzzle.

Now, to start, I have a class for the number generator, a class to store the array of 25 words, and a class for the game itself.

View Replies View Related

Word Puzzle Game - Add Extra No Occurrences

Oct 20, 2014

I have a simple Word Program here called PuzzleGame.java. It works perfectly but I wanted to add some bells and whistles to it. So I want to be able that if the user selects the same letter more than once a message comes up letting the user know that "That letter has already been selected, try another letter."

I am certain that if would go in the 'else' of the 'if( )' that I am providing.

import java.util.Scanner;
public class PuzzleGame {
public static void main(String[] args){
String secretPhrase = "BIG JAVA";
String guesses = " ";

[Code] .....

I am thinking maybe after the else in this if statement.

if(guesses.indexOf(secretLetter)== -1) {
System.out.print("-");
notDone = true;
} else {
//something here. I am not sure how to go about it.
System.out.print(secretLetter);
}

View Replies View Related

Multi-word Hangman Game - Spaces Not Displayed When Program Run

Apr 9, 2015

I created a simple Hangman game. It functions correctly, the only issue is when the file contains a phrase (2 or more words), spaces are not displayed when the program is run. For example, if the phrase was Java Programming Forums.

It would appear as _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _.

I want there to be spaces in between the words. How could I fix this? What would I need to add to my code?

import java.util.Scanner;
import java.io.*;
 public class hangman{
public static void main (String[] args) throws FileNotFoundException{
Scanner kb = new Scanner(System.in);
String guess;
String guesses = "";
int wrongGuess = 8;

[Code] ....

View Replies View Related

Hangman Type Game - How Many Times Each Guessed Letter Occurs Within The Word

Jul 31, 2014

The game runs fine, however I have to include how many times each letter that is guessed occurs within the word. For example, if the guess is e, the program should print out: The character e occurs in 3 positions. How would I go about doing this??

/*
* A program that plays simple word guessing game. In this game the user provides a list of words to the program.
* The program randomly selects one of the words to be guessed from this list.
* The player then guesses letters in an attempt to figure out what the hidden word might be.
* The number of guesses that the user takes are tracked and reported at the end of the game.
*/

import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;

[Code] .....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved