I do use some java, though I'm not the best at graphics. PM me or on Skype if you need some help.
baseballlover312, 06-03-14 : "Nuke Moscow...Don't worry Russia, we've got plenty of love to go around your cities"
Sarah Palin, 08-03-14 (CPAC, on Russian aggression) : "The only thing that stops a bad guy with a nuke is a good guy with a nuke"
Big thanks to jdog for making this AMAZING userbar!
jseadog1 wrote:
Anybody here have any experience using JAVA code? I could use some help right now building a keno game.
I can do template programs and corrections, but not much source writing. Just skype me if you still need help. ;)
I'll just post it here, the hell with it..
I have a keno game, and I am trying to turn my matches of compDraw & MyPicks to green, and the compDraw to Yellow. I was successfully able to set my picks as red, but am stuck now.
// constants
public static final int WIDTH = 4;
public static final int HEIGHT = 20;
public static final int INITIAL = 0;
public static final int RED = 1;
public static final int YELLOW = 3;
public static final int CHECKED = 4;
private int turn = RED; // to track which player should play next
private int[][] playerGrid; // to record each player's move
private int[][] shadowGrid; // to keep track of which atoms have been FOUND
private int[][] crystalGrid; // to extract a single crystal from playerGrid
private int row, column; // position of most recently added atom
private int lowX, lowY, highX, highY; // corner coordinates of current crystal
private int player1Score = 0;
private int player2Score = 0;
myPicks = new boolean [81];
compDraw = new boolean [81]; }
// GUI related fields
private JButton[] buttonArray;
// private JTextField scoreField1;
// private JTextField scoreField2;
// private JLabel labelRED; // Label "Red" on GUI
// private JLabel labelYELLOW; // Label "Yellow" on GUI
private JLabel labelTurn; // Label displays whose turn is next
private int numberToSelect = 20;
Keno() {
createGUIAndPlay();
}
private void createGUIAndPlay() {
final JFrame f = new JFrame();
// create the panels
JPanel topPanel = new JPanel(new BorderLayout());
JPanel buttonPanel = new JPanel(new GridLayout(WIDTH, HEIGHT));
JPanel labelPanel = new JPanel();
// represents the 2D grid of buttons on the GUI
buttonArray = new JButton[WIDTH * HEIGHT];
// stores the positions of atoms in both player's crystals
playerGrid = new int[WIDTH][HEIGHT];
// shadowGrid keeps track of which atoms have been found
shadowGrid = new int[WIDTH][HEIGHT];
// used to store a crystal to determine if it is a perfect crystal
crystalGrid = new int[WIDTH][HEIGHT];
JTextField Bet = new JTextField("Bet:");
JButton endGameButton = new JButton("Start Draw");
// labelRED = new JLabel("Red");
labelTurn = new JLabel(Integer.toString(numberToSelect), Label.LEFT);
Dimension dim = labelTurn.getPreferredSize();
labelTurn.setPreferredSize(new Dimension(dim.width+100, dim.height+10));
// create the buttons on which players will make their moves
for (int i = 0; i < HEIGHT * WIDTH; i++) {
buttonArray[i] = new JButton(Integer.toString(i+1));
buttonPanel.add(buttonArray[i]);
}
final Color buttColor = buttonArray[0].getBackground();
// add the action listener to the buttons
for (int i = 0; i < HEIGHT * WIDTH; i++) {
buttonArray[i].setActionCommand(Integer.toString(i));
buttonArray[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton button = (JButton) e.getSource();
if (button.getBackground() == Color.RED) {
button.setBackground(buttColor);
myPicks[Integer.parseInt(button.getActionCommand())] = false;
numberToSelect++;
}
else {
if (numberToSelect > 0) {
button.setBackground(Color.RED);
myPicks[Integer.parseInt(button.getActionCommand())] = true;
numberToSelect--;
}
}
// button.setEnabled(false);
int buttonIndex = Integer.valueOf(button.getActionCommand());
row = buttonIndex/WIDTH;
column = buttonIndex % WIDTH;
// playMove();
endGameButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String s;
int numLeft = 20;
while (numLeft > 0); {
int numDraw = (int)(Math.random() * 80 + 1);
if (!compDraw[numDraw]){
compDraw[numDraw] = true;
numLeft--;
}
}
// each time a "ball" matches one selected on the Keno ticket add to a counter
// at end look up payout for the number of matches corresponding to the counter
if (player1Score > player2Score)
s = "RED wins the game";
else if(player1Score < player2Score)
s = "YELLOW wins the game";
else
s = "Game is a draw";
JOptionPane.showMessageDialog(f, s, "Game Over", JOptionPane.PLAIN_MESSAGE);
System.exit(1);
}
});
endGameButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String s;
int numLeft = 20;
while (numLeft > 0); {
int numDraw = (int)(Math.random() * 80 + 1);
if (!compDraw[numDraw]){
compDraw[numDraw] = true;
numLeft--;
somewhere in there I need to do what I stated above :|
I use eclipse, it is a HUGE help.
PCM.Daily Survivor Season 2 Fan Favorite Winner
PCM.Daily NFL Fantasy Football Champion: 2012 PCM.Daily NHL Prediction Game Champion: 2013 PCM.Daily NFL Prediction Game Champion:
2012, 2013, 2015, 2016, 2021, 2024, 2025
jseadog1 wrote:
Anybody here have any experience using JAVA code? I could use some help right now building a keno game.
I can do template programs and corrections, but not much source writing. Just skype me if you still need help. ;)
Spoiler
I'll just post it here, the hell with it..
I have a keno game, and I am trying to turn my matches of compDraw & MyPicks to green, and the compDraw to Yellow. I was successfully able to set my picks as red, but am stuck now.
// constants
public static final int WIDTH = 4;
public static final int HEIGHT = 20;
public static final int INITIAL = 0;
public static final int RED = 1;
public static final int YELLOW = 3;
public static final int CHECKED = 4;
private int turn = RED; // to track which player should play next
private int[][] playerGrid; // to record each player's move
private int[][] shadowGrid; // to keep track of which atoms have been FOUND
private int[][] crystalGrid; // to extract a single crystal from playerGrid
private int row, column; // position of most recently added atom
private int lowX, lowY, highX, highY; // corner coordinates of current crystal
private int player1Score = 0;
private int player2Score = 0;
myPicks = new boolean [81];
compDraw = new boolean [81]; }
// GUI related fields
private JButton[] buttonArray;
// private JTextField scoreField1;
// private JTextField scoreField2;
// private JLabel labelRED; // Label "Red" on GUI
// private JLabel labelYELLOW; // Label "Yellow" on GUI
private JLabel labelTurn; // Label displays whose turn is next
private int numberToSelect = 20;
Keno() {
createGUIAndPlay();
}
private void createGUIAndPlay() {
final JFrame f = new JFrame();
// create the panels
JPanel topPanel = new JPanel(new BorderLayout());
JPanel buttonPanel = new JPanel(new GridLayout(WIDTH, HEIGHT));
JPanel labelPanel = new JPanel();
// represents the 2D grid of buttons on the GUI
buttonArray = new JButton[WIDTH * HEIGHT];
// stores the positions of atoms in both player's crystals
playerGrid = new int[WIDTH][HEIGHT];
// shadowGrid keeps track of which atoms have been found
shadowGrid = new int[WIDTH][HEIGHT];
// used to store a crystal to determine if it is a perfect crystal
crystalGrid = new int[WIDTH][HEIGHT];
JTextField Bet = new JTextField("Bet:");
JButton endGameButton = new JButton("Start Draw");
// labelRED = new JLabel("Red");
labelTurn = new JLabel(Integer.toString(numberToSelect), Label.LEFT);
Dimension dim = labelTurn.getPreferredSize();
labelTurn.setPreferredSize(new Dimension(dim.width+100, dim.height+10));
// create the buttons on which players will make their moves
for (int i = 0; i < HEIGHT * WIDTH; i++) {
buttonArray[i] = new JButton(Integer.toString(i+1));
buttonPanel.add(buttonArray[i]);
}
final Color buttColor = buttonArray[0].getBackground();
// add the action listener to the buttons
for (int i = 0; i < HEIGHT * WIDTH; i++) {
buttonArray[i].setActionCommand(Integer.toString(i));
buttonArray[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton button = (JButton) e.getSource();
if (button.getBackground() == Color.RED) {
button.setBackground(buttColor);
myPicks[Integer.parseInt(button.getActionCommand())] = false;
numberToSelect++;
}
else {
if (numberToSelect > 0) {
button.setBackground(Color.RED);
myPicks[Integer.parseInt(button.getActionCommand())] = true;
numberToSelect--;
}
}
// button.setEnabled(false);
int buttonIndex = Integer.valueOf(button.getActionCommand());
row = buttonIndex/WIDTH;
column = buttonIndex % WIDTH;
// playMove();
endGameButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String s;
int numLeft = 20;
while (numLeft > 0); {
int numDraw = (int)(Math.random() * 80 + 1);
if (!compDraw[numDraw]){
compDraw[numDraw] = true;
numLeft--;
}
}
// each time a "ball" matches one selected on the Keno ticket add to a counter
// at end look up payout for the number of matches corresponding to the counter
if (player1Score > player2Score)
s = "RED wins the game";
else if(player1Score < player2Score)
s = "YELLOW wins the game";
else
s = "Game is a draw";
JOptionPane.showMessageDialog(f, s, "Game Over", JOptionPane.PLAIN_MESSAGE);
System.exit(1);
}
});
endGameButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String s;
int numLeft = 20;
while (numLeft > 0); {
int numDraw = (int)(Math.random() * 80 + 1);
if (!compDraw[numDraw]){
compDraw[numDraw] = true;
numLeft--;
somewhere in there I need to do what I stated above :|
I use eclipse, it is a HUGE help[/spoiler].
I'm not sure I understand your problem. Is the issue that you want to create green picks and can't? If so, you need to add 'green" as a constant, then manipulate the variable set to incorporate "green".
"America. Show a nipple on television and the whole country goes ape-shit." -DubbelDekker
jseadog1 wrote:
Anybody here have any experience using JAVA code? I could use some help right now building a keno game.
I can do template programs and corrections, but not much source writing. Just skype me if you still need help. ;)
Spoiler
I'll just post it here, the hell with it..
I have a keno game, and I am trying to turn my matches of compDraw & MyPicks to green, and the compDraw to Yellow. I was successfully able to set my picks as red, but am stuck now.
// constants
public static final int WIDTH = 4;
public static final int HEIGHT = 20;
public static final int INITIAL = 0;
public static final int RED = 1;
public static final int YELLOW = 3;
public static final int CHECKED = 4;
private int turn = RED; // to track which player should play next
private int[][] playerGrid; // to record each player's move
private int[][] shadowGrid; // to keep track of which atoms have been FOUND
private int[][] crystalGrid; // to extract a single crystal from playerGrid
private int row, column; // position of most recently added atom
private int lowX, lowY, highX, highY; // corner coordinates of current crystal
private int player1Score = 0;
private int player2Score = 0;
myPicks = new boolean [81];
compDraw = new boolean [81]; }
// GUI related fields
private JButton[] buttonArray;
// private JTextField scoreField1;
// private JTextField scoreField2;
// private JLabel labelRED; // Label "Red" on GUI
// private JLabel labelYELLOW; // Label "Yellow" on GUI
private JLabel labelTurn; // Label displays whose turn is next
private int numberToSelect = 20;
Keno() {
createGUIAndPlay();
}
private void createGUIAndPlay() {
final JFrame f = new JFrame();
// create the panels
JPanel topPanel = new JPanel(new BorderLayout());
JPanel buttonPanel = new JPanel(new GridLayout(WIDTH, HEIGHT));
JPanel labelPanel = new JPanel();
// represents the 2D grid of buttons on the GUI
buttonArray = new JButton[WIDTH * HEIGHT];
// stores the positions of atoms in both player's crystals
playerGrid = new int[WIDTH][HEIGHT];
// shadowGrid keeps track of which atoms have been found
shadowGrid = new int[WIDTH][HEIGHT];
// used to store a crystal to determine if it is a perfect crystal
crystalGrid = new int[WIDTH][HEIGHT];
JTextField Bet = new JTextField("Bet:");
JButton endGameButton = new JButton("Start Draw");
// labelRED = new JLabel("Red");
labelTurn = new JLabel(Integer.toString(numberToSelect), Label.LEFT);
Dimension dim = labelTurn.getPreferredSize();
labelTurn.setPreferredSize(new Dimension(dim.width+100, dim.height+10));
// create the buttons on which players will make their moves
for (int i = 0; i < HEIGHT * WIDTH; i++) {
buttonArray[i] = new JButton(Integer.toString(i+1));
buttonPanel.add(buttonArray[i]);
}
final Color buttColor = buttonArray[0].getBackground();
// add the action listener to the buttons
for (int i = 0; i < HEIGHT * WIDTH; i++) {
buttonArray[i].setActionCommand(Integer.toString(i));
buttonArray[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton button = (JButton) e.getSource();
if (button.getBackground() == Color.RED) {
button.setBackground(buttColor);
myPicks[Integer.parseInt(button.getActionCommand())] = false;
numberToSelect++;
}
else {
if (numberToSelect > 0) {
button.setBackground(Color.RED);
myPicks[Integer.parseInt(button.getActionCommand())] = true;
numberToSelect--;
}
}
// button.setEnabled(false);
int buttonIndex = Integer.valueOf(button.getActionCommand());
row = buttonIndex/WIDTH;
column = buttonIndex % WIDTH;
// playMove();
endGameButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String s;
int numLeft = 20;
while (numLeft > 0); {
int numDraw = (int)(Math.random() * 80 + 1);
if (!compDraw[numDraw]){
compDraw[numDraw] = true;
numLeft--;
}
}
// each time a "ball" matches one selected on the Keno ticket add to a counter
// at end look up payout for the number of matches corresponding to the counter
if (player1Score > player2Score)
s = "RED wins the game";
else if(player1Score < player2Score)
s = "YELLOW wins the game";
else
s = "Game is a draw";
JOptionPane.showMessageDialog(f, s, "Game Over", JOptionPane.PLAIN_MESSAGE);
System.exit(1);
}
});
endGameButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String s;
int numLeft = 20;
while (numLeft > 0); {
int numDraw = (int)(Math.random() * 80 + 1);
if (!compDraw[numDraw]){
compDraw[numDraw] = true;
numLeft--;
somewhere in there I need to do what I stated above :|
I use eclipse, it is a HUGE help[/spoiler].
I'm not sure I understand your problem. Is the issue that you want to create green picks and can't? If so, you need to add 'green" as a constant, then manipulate the variable set to incorporate "green".
The problem is this:
I don't know what code to put in where when CompDraw = myPicks it turns green, ELSE, it turns yellow.
PCM.Daily Survivor Season 2 Fan Favorite Winner
PCM.Daily NFL Fantasy Football Champion: 2012 PCM.Daily NHL Prediction Game Champion: 2013 PCM.Daily NFL Prediction Game Champion:
2012, 2013, 2015, 2016, 2021, 2024, 2025
While we're on the topic of coding, anyone try USACO this weekend? I gave it a shot and got a couple of them, though the last ones were too hard for me
baseballlover312, 06-03-14 : "Nuke Moscow...Don't worry Russia, we've got plenty of love to go around your cities"
Sarah Palin, 08-03-14 (CPAC, on Russian aggression) : "The only thing that stops a bad guy with a nuke is a good guy with a nuke"
Big thanks to jdog for making this AMAZING userbar!
MARSUPILAMI wrote: My teacher finally put me a 9.9
Why the fuck do you foreigners use the decimals in the votes?
It doesn't make sense at all! When I used to go to the middle school the votes scale used to be like this:
Biology = 10
Chemistry & Physics = 10
Geography = 10
Religion = 10
Music = 10
Technology = 10
English = 9
Maths = 9
Language = 9
Physical Education = 9
French = 8
Art = 6
Those are my marks! All of them in a 0-10 scale! Judge them! (My English & Frecnh and my Art teachers are really silly. For example, in French I had 8.75 and 8.8 in exams... and she put me an 8! In English I had 8.4, 9.8 and 9.9... and she put me a 9! And in Art... he is subnormal...)
That looks pretty good, my marks aren't even close to that.
I have to ask you though, at your point, are the levels still mixed or are they seperated?
(In other words, are you only with kids of your level or is everyone still mixed, like primary school?)
I am with kids of my age, not of my level (I am more clever than them).
And I have to say that, when I was 6, I jumped 1st Primary and I came to 2nd Primary, so I am with kids even older than me! (a year) Really (maybe you think I´m lying, but not, it´s true) I am "exceptionally gifted" (Google Translate a lot of clever)
Ah well that explains why your marks are exceptionally high. (When) are the levels seperated in Spain? Because imo it's not a good thing if you stay with people that are, well, a lot less intelligent. One should get lessons of his own level.
Spanish people aren't clever... They just siesta and fiesta all day long...
Bit more serious: Those grades are great for any level really, no matter what. You may not be the most artistic person, but who cares? All art studies are guaranteed to give you no job, unless you're extremely talented...
Manager of Team Popo4Ever p/b Morshynska in the PCM.Daily Man-Game