-
Can anyone help a complete idiot like me !
Hi
how do i make this into a two- player game. Also Could some tell me how would the java program put X's on numbers matched in the bingo game instead of -1s and also produce acsending number list for each column of the bing card.
i want it to
1. prompt for the name of the second player
2. Get the name and store it in a variable
3.create a player object for the player
4 .create a grid2 object for the plaey
Class being used : BingoGame,Grid2,UnqiueRandomNumber,console,Player.
please help i have spent over five hours fiddleing with the code no luck it.
thanks to every1 who will help me with this!
if anyone needs to see any of the other classes then please ask me !
public class BingoGame {
public static void main(String[] args) {
// 1. User starts game
// DISPLAY welcome message
System.out.println("Welcome to bingo");
System.out.println("Instructions");
System.out.println("------------");
System.out.println("Please Enter your details");
// DISPLAY prompt first player to enter their name
System.out.println("Player 1, please enter your name");
// DECLARE a String object variable to store the name of player
String player1name;
// ASSIGN the name of the player typed in from the keyboard to player1name
player1name = Console.readFromKeyboard();
// MAKE a Player object to store player details
Player player1 = new Player();
// INVOKE setName to store the name of the player
player1.setName(player1name);
// MAKE a Grid2 object to represent the player's card
Grid2 player1card = new Grid2();
// INVOKE createGrid to set up the grid to the specified number of rows and columns
player1card.createGrid(5,5);
// DISPLAY a blank line to start game on a new line
// 2. Game play begins
// MAKE a BingoRules object to carry out rules of bingo
BingoRules rules = new BingoRules();
// MAKE a UniqueRandom6 class to simulate the bingo machine
UniqueRandom6 bingoMachine = new UniqueRandom6(50);
// DISPLAY player 1's card
System.out.println(player1.getName() + "'s bingo card");
// INVOKE displayGrid to display the grid of numbers
player1card.displayGrid();
// DISPLAY a blank line to start game on a new line
System.out.println();
// LOOP until one player has won
while (rules.checkCardForWinningLines(player1card, 1) != true) {
// DECLARE an int variable to store the random number generated to represent the ball
int ballNumber;
// ASSIGN a random number as the "ball" number called
ballNumber = bingoMachine.nextNumber() + 1;
// DISPLAY the number on the screen
System.out.println("Number called = " + ballNumber);
// IF the number is on the card then cross it off
if (rules.findNumber(player1card, ballNumber)) {
// INVOKE crossOffNumber to update card
rules.crossOffNumber(player1card, ballNumber);
}
// DISPLAY player 1's card
System.out.println(player1.getName() + "'s bingo card");
// INVOKE displayGrid to display the grid of numbers
player1card.displayGrid();
// DISPLAY a blank line to start game on a new line
System.out.println();
// END LOOP
//DISPLAY player 1's card
System.out.println(player1.getName() + "'s bingo card");
// INVOKE displayGrid to display the grid of numbers
player1card.displayGrid();
// DISPLAY a blank line to start game on a new line
System.out.println();
//END LOOP
}
// IF player 1 has won display winning message
if (rules.checkCardForWinningLines(player1card, 1)) {
System.out.println("Well done " + player1.getName() + ", you're a winner!!!!");
}
}
}
Thank you please help me !
-
You have made the most of your program in the main class, but as I see it you will have to make a client/server solution otherwise the 2 players will have to be on the same machine. This should also help you with the prompting for the player name. You could make a login panel when a client is connected to the server and here you could ask for the playernames. This way there will be no difference between player 1 and 2 and you could scale to more then just 2 players. I know it is not much of a help to the current problem.
But as I see it you can not make multiple gaming whitout using the client/server solution.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks