Results 1 to 20 of 30
Thread: Pig Game Lab
- 02-15-2012, 02:47 AM #1
Member
- Join Date
- Feb 2012
- Location
- Texas
- Posts
- 20
- Rep Power
- 0
Pig Game Lab
Can someone help me with a Pig Game Lab? I have to do the Human Player Part. So far I have this, and I need help on where to begin:
import static java.lang.System.*;
import java.util.*;
import java.awt.*;
import javax.swing.*;
import java.io.*;
import java.util.Scanner.*;
public class HumanPlayer {
private int scoreOfPlayer;
private int totalOfRolls;
int scoreOfPlayer = 0;
int totalOfRolls = 0;
Scanner kb = new Scanner(System.in);
System.out.println("It's your turn to roll the dice.");
}
Need help on it. Thank you for your time!
- 02-15-2012, 02:49 AM #2
Re: Pig Game Lab
Not a lot to go on. What is supposed to happen next? Is the program supposed to get some input from the user?
- 02-15-2012, 02:55 AM #3
Member
- Join Date
- Feb 2012
- Location
- Texas
- Posts
- 20
- Rep Power
- 0
Re: Pig Game Lab
Well, I need to construct a method. It's supposed to calculate scores and have a roll button for dice which is made by my other group partner. But I'm stuck, and it's due tomorrow. Can you/others help me on this lab?
-
Re: Pig Game Lab
Still not a lot to go on. You need to tell us exactly what you're trying to do, you need to tell us exactly where you're stuck and you need to show your code attempt to solve this. Also you need to understand that no one here will do this for you of course, but we will try to nudge you in the right direction and give you links to tutorials so hopefully you can learn to solve this yourself.
- 02-15-2012, 03:00 AM #5
Re: Pig Game Lab
What exactly are you stuck on ? I't seems that you only recently started with your project ?
- 02-15-2012, 03:01 AM #6
Re: Pig Game Lab
Before you can write the code you need to describe what it is supposed to do.
When you have that,
for a method you need to know what it will return and what parameters it needs.
Then you'd write the code, compile it and test it.
What do you have so far? Post the code, your description of what its to do and your questions.
have a roll button for dice
- 02-15-2012, 03:12 AM #7
Member
- Join Date
- Feb 2012
- Location
- Texas
- Posts
- 20
- Rep Power
- 0
Re: Pig Game Lab
Okay so I have to determine first player which is a HumanPlayer. Then I have to roll a die. (which my partner will do) After that, I have to display current turn score with the new die roll. Then prompt if they want to end the turn or continue to roll. Finally, I have to display a total game score.
- 02-15-2012, 03:15 AM #8
Re: Pig Game Lab
have to determine first player which is a HumanPlayer
- 02-15-2012, 03:19 AM #9
Member
- Join Date
- Feb 2012
- Location
- Texas
- Posts
- 20
- Rep Power
- 0
Re: Pig Game Lab
Sorry if I'm not clear enough because this lab could be hard for me, I just make a String variable stating the HumanPlayer. You don't have to ask the user a question.
- 02-15-2012, 03:24 AM #10
Re: Pig Game Lab
You don't have to ask the user a question
Can you explain the next thing the program is supposed to do after it prints out the message: It's your turn to roll the dice.
- 02-15-2012, 03:26 AM #11
Member
- Join Date
- Feb 2012
- Location
- Texas
- Posts
- 20
- Rep Power
- 0
Re: Pig Game Lab
They have to press a button that rolls the dice. And it calculates the outcome score after the user rolls the dice. At the end, there is a question asking whether or not the user wants to end the turn or keep on rolling. Then the user enters their input which will update the score board and switches to the computer player.
- 02-15-2012, 03:30 AM #12
Re: Pig Game Lab
They have to press a button that rolls the dice
You don't use the Scanner class with a GUI program.
I suggest that you leave the GUI for the next project and stick with simple console input.
- 02-15-2012, 03:39 AM #13
Member
- Join Date
- Feb 2012
- Location
- Texas
- Posts
- 20
- Rep Power
- 0
Re: Pig Game Lab
Okay, I don't have to use scanner. I guess window is okay, but I make it simple using the general output window. Problem is I have two errors with the statement line System.out.println("It's your turn to roll the dice."); I have an error on that.
- 02-15-2012, 03:42 AM #14
Re: Pig Game Lab
Also with a GUI application you do not use System.out.println to tell the user anything.
System.out.println would be used for debug output to find program problems.
If you get errors, you need to post the full text here.
- 02-15-2012, 03:47 AM #15
Member
- Join Date
- Feb 2012
- Location
- Texas
- Posts
- 20
- Rep Power
- 0
Re: Pig Game Lab
As in the error line like this?: System.out.println("It's your turn to roll the dice.");
My full text is the first post if you need it.
- 02-15-2012, 03:48 AM #16
Re: Pig Game Lab
Please copy full text of error message and paste it here. Here is a sample:
Java Code:TestSorts.java:138: cannot find symbol symbol : variable var location: class TestSorts var = 2; ^
- 02-15-2012, 03:57 AM #17
Member
- Join Date
- Feb 2012
- Location
- Texas
- Posts
- 20
- Rep Power
- 0
Re: Pig Game Lab
Sorry I couldn't do it like that because I tried to build on file but failed to do so. So I improvised my own. <identifier> expected and illegal start of type System.out.println("It's your turn to roll the dice.");
- 02-15-2012, 04:00 AM #18
Re: Pig Game Lab
The code with the error needs to be inside of a method.
- 02-15-2012, 04:04 AM #19
Member
- Join Date
- Feb 2012
- Location
- Texas
- Posts
- 20
- Rep Power
- 0
Re: Pig Game Lab
Can you show me an example of it? Sorry, I'm still new to Java and I have troubles with methods alot of times.
- 02-15-2012, 04:05 AM #20
Re: Pig Game Lab
Here's a link to the java tutorials that will show you some examples:
"Hello World!" for Microsoft Windows (The Java™ Tutorials > Getting Started > The "Hello World!" Application)
http://docs.oracle.com/javase/tutorial/java/TOC.html
Similar Threads
-
Complete Game Engine for beginner and intermediate game programmers
By rdjava in forum Java GamingReplies: 1Last Post: 06-02-2011, 10:29 AM -
Implementing "Game Over" in Minesweeper game based on Gridworld framework.
By JFlash in forum New To JavaReplies: 2Last Post: 08-05-2010, 05:49 AM -
game code for any game
By deathnote202 in forum Java GamingReplies: 4Last Post: 06-10-2010, 09:06 AM -
can someone help me with this game??
By amalina in forum New To JavaReplies: 1Last Post: 08-24-2009, 06:59 AM -
2D strategy game or 2D war game
By led1433 in forum Java 2DReplies: 5Last Post: 02-10-2009, 07:00 AM
Bookmarks