i have this problem about the betting system of my game. Here's the scenario:
Your money: 300
Your bet: 300
JOptionPane appears: "you have insufficient money to bet"
Here's the code for the main program:
/*
* 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.
*/
package dicegame;
import javax.swing.JOptionPane;
/**
*
* @author USER
*/
public class dicegame13 extends javax.swing.JFrame {
verify check = new verify();
int catcher=0;
int dealersTurn=0;
int ctrTurn=0, ctr2=1;
int yourMoney=0,yourBet=0,Earnings=0,totalMoney=0, hold=0;
int a1=0,a2=0,a3=0,a4=0,a5=0,b1=0,b2=0;
int identity[] = new int [5];
public dicegame13() {
JOptionPane.showMessageDialog(null,"Place your Money first");
initComponents();
setResizable(false);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
d2 = new javax.swing.JButton();
d3 = new javax.swing.JButton();
d4 = new javax.swing.JButton();
d1 = new javax.swing.JButton();
d5 = new javax.swing.JButton();
stayButton = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
playon = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
d2.setEnabled(false);
d2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
d2ActionPerformed(evt);
}
});
d3.setEnabled(false);
d3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
d3ActionPerformed(evt);
}
});
d4.setEnabled(false);
d4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
d4ActionPerformed(evt);
}
});
d1.setEnabled(false);
d1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
d1ActionPerformed(evt);
}
});
d5.setEnabled(false);
d5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
d5ActionPerformed(evt);
}
});
stayButton.setFont(new java.awt.Font("Microsoft JhengHei", 1, 48)); // NOI18N
stayButton.setText("Stay");
stayButton.setEnabled(false);
stayButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
stayButtonActionPerformed(evt);
}
});
jLabel3.setText("Earnings:");
jLabel4.setText("Total Money:");
jLabel2.setText("Your Money Started with:");
jLabel5.setText("Your Bet:");
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
jTextField2.setEnabled(false);
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});
jTextField3.setEnabled(false);
jTextField4.setEnabled(false);
jButton1.setFont(new java.awt.Font("Lucida Bright", 1, 24)); // NOI18N
jButton1.setText("START!");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("Place Bet");
jButton2.setEnabled(false);
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
playon.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
playon.setText("Play on!");
playon.setEnabled(false);
playon.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
playonActionPerformed(evt);
}
});
jButton3.setText("Quit");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(27, 27, 27)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(d1, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(d5, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(d2, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(212, 212, 212))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel5)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jButton2))
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(46, 46, 46)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(d3, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(stayButton, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(d4, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jTextField3)
.addComponent(jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)))))
.addGroup(layout.createSequentialGroup()
.addGap(74, 74, 74)
.addComponent(playon, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel5)
.addGap(8, 8, 8)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2))))
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(31, 31, 31)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(d3, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(d4, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(d2, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(d5, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(d1, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(stayButton)
.addComponent(playon, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton3))
.addGap(25, 25, 25))
);
pack();
}// </editor-fold>
private void stayButtonActionPerformed(java.awt.event.ActionEvent evt) {
last();
}
private void d1ActionPerformed(java.awt.event.ActionEvent evt) {
int got = 13;
a1=(int) (Math.random()*6+1);
check.holdValue1(a1);
String dice =Integer.toString(a1);
identity[0]=1;
ctr2++;
catcher=check.adder();
d1.setText(dice);
d1.setEnabled(false);
d2.setEnabled(true);
if(catcher==got){
JOptionPane.showMessageDialog(null, "You win!");
Earnings=Earnings+yourBet;
jTextField3.setText(Earnings+"");
totalMoney=totalMoney+Earnings+yourBet;
jTextField4.setText(totalMoney+"");
playon.setEnabled(true);
}
else if (catcher>got){
JOptionPane.showMessageDialog(null, "You lose!");
stayButton.setEnabled(false);
Earnings=Earnings-yourBet;
jTextField3.setText(Earnings+"");
totalMoney=totalMoney+Earnings;
// totalMoney=totalMoney-yourBet;
jTextField4.setText(totalMoney+"");
}
if (ctr2==6)
{
last();
}
playon.setEnabled(true);
}
private void d2ActionPerformed(java.awt.event.ActionEvent evt) {
int got = 13;
a2=(int) (Math.random()*6+1);
check.holdValue2(a2);
String dice =Integer.toString(a2);
ctr2++;
identity[1]=2;
catcher=check.adder();
d2.setText(dice);
d2.setEnabled(false);
d3.setEnabled(true);
if(catcher==got){
JOptionPane.showMessageDialog(null, "You win!");
Earnings=Earnings+yourBet;
jTextField3.setText(Earnings+"");
totalMoney=totalMoney+Earnings+yourBet;
jTextField4.setText(totalMoney+"");
playon.setEnabled(true);
}
else if (catcher>got){
JOptionPane.showMessageDialog(null, "You lose!");
stayButton.setEnabled(false);
Earnings=Earnings-yourBet;
jTextField3.setText(Earnings+"");
totalMoney=totalMoney+Earnings;
// totalMoney=totalMoney-yourBet;
jTextField4.setText(totalMoney+"");
}
if (ctr2==6)
{
last();
}
playon.setEnabled(true);
}
private void d3ActionPerformed(java.awt.event.ActionEvent evt) {
int got = 13;
a3=(int) (Math.random()*2+1);
check.holdValue3(a3);
String dice =Integer.toString(a3);
ctr2++;
identity[2]=3;
catcher=check.adder();
d3.setText(dice);
d3.setEnabled(false);
d4.setEnabled(true);
if(catcher==got){
JOptionPane.showMessageDialog(null, "You win!");
Earnings=Earnings+yourBet;
jTextField3.setText(Earnings+"");
totalMoney=totalMoney+Earnings+yourBet;
jTextField4.setText(totalMoney+"");
playon.setEnabled(true);
}
else if (catcher>got){
JOptionPane.showMessageDialog(null, "You lose!");
stayButton.setEnabled(false);
Earnings=Earnings-yourBet;
jTextField3.setText(Earnings+"");
totalMoney=totalMoney+Earnings;
// totalMoney=totalMoney-yourBet;
jTextField4.setText(totalMoney+"");
}
if (ctr2==6)
{
last();
}
playon.setEnabled(true);
}
private void d4ActionPerformed(java.awt.event.ActionEvent evt) {
int got = 13;
a4=(int) (Math.random()*2+1);
check.holdValue4(a4);
String dice =Integer.toString(a4);
ctr2++;
identity[3]=4;
catcher=check.adder();
d4.setText(dice);
d4.setEnabled(false);
d5.setEnabled(true);
if(catcher==got){
JOptionPane.showMessageDialog(null, "You win!");
stayButton.setEnabled(false);
Earnings=Earnings+yourBet;
jTextField3.setText(Earnings+"");
totalMoney=totalMoney+Earnings+yourBet;
jTextField4.setText(totalMoney+"");
playon.setEnabled(true);
}
else if (catcher>got){
JOptionPane.showMessageDialog(null, "You lose!");
Earnings=Earnings-yourBet;
jTextField3.setText(Earnings+"");
totalMoney=totalMoney+Earnings;
// totalMoney=totalMoney-yourBet;
jTextField4.setText(totalMoney+"");
}
if (ctr2==6)
{
last();
}
playon.setEnabled(true);
}
private void d5ActionPerformed(java.awt.event.ActionEvent evt) {
int got = 13;
a5=(int) (Math.random()*2+1);
check.holdValue5(a5);
String dice =Integer.toString(a5);
ctr2++;
identity[4]=5;
catcher=check.adder();
d5.setText(dice);
d5.setEnabled(false);
if(catcher==got){
JOptionPane.showMessageDialog(null, "You win!");
Earnings=Earnings+yourBet;
jTextField3.setText(Earnings+"");
totalMoney=totalMoney+Earnings+yourBet;
jTextField4.setText(totalMoney+"");
playon.setEnabled(true);
}
else if (catcher>got){
JOptionPane.showMessageDialog(null, "You lose!");
stayButton.setEnabled(false);
Earnings=Earnings-yourBet;
jTextField3.setText(Earnings+"");
totalMoney=totalMoney+Earnings;
// totalMoney=totalMoney-yourBet;
jTextField4.setText(totalMoney+"");
}
if (ctr2==6)
{
last();
}
playon.setEnabled(true);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jButton2.setEnabled(true);
jTextField1.setEditable(false);
jTextField2.setEnabled(true);
yourMoney=Integer.parseInt(jTextField1.getText());
yourMoney=hold;
hold=totalMoney;
jButton1.setText("Your Turn");
jButton1.setEnabled(false);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jButton2.setEnabled(false);
yourBet=Integer.parseInt(jTextField2.getText());
if (yourBet>yourMoney)
{
JOptionPane.showMessageDialog(null,"You have insufficient money to bet");
jButton2.setEnabled(true);
}
else {
jButton2.setEnabled(false);
stayButton.setEnabled(true);
jTextField2.setEditable(false);
yourMoney=yourMoney-yourBet;
// jTextField1.setText(yourMoney+"");
d1.setEnabled(true);
d2.setEnabled(true);
d3.setEnabled(true);
d4.setEnabled(true);
d5.setEnabled(true);
stayButton.setEnabled(true);
}
}
private void playonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jButton2.setEnabled(true);
jTextField2.setEditable(true);
ctrTurn=0;
ctr2=1;
a1=0;a2=0;a3=0;a4=0;a5=0; b1=0;b2=0;
dealersTurn=0;catcher=0;
d1.setText("");
d2.setText("");
d3.setText("");
d4.setText("");
d5.setText("");
d1.setEnabled(false);
d2.setEnabled(false);
d3.setEnabled(false);
d4.setEnabled(false);
d5.setEnabled(false);
stayButton.setEnabled(true);
jButton1.setText("Your turn!");
check.holdDVal(0);
check.holdValue1(0);
check.holdValue2(0);
check.holdValue3(0);
check.holdValue4(0);
check.holdValue5(0);
jTextField2.setText("0");
}
private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
MainMenu run = new MainMenu();
run.setVisible(true);
setVisible(false);
}
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
public void last(){
ctrTurn++;
stayButton.setEnabled(false);
if (ctrTurn==1)
jButton1.setText("Dealer's Turn");
ctrTurn=0;
d1.setEnabled(true);
d2.setEnabled(true);
d3.setEnabled(true);
d4.setEnabled(true);
d5.setEnabled(true);
d1.setText("");
d2.setText("");
d3.setText("");
d4.setText("");
d5.setText("");
b1=(int) (Math.random()*5+2);
for (int i=1; i<=b1; i++)
{
b2=(int) (Math.random()*6+1);
// identity[i]= b2;
if (i==1){
d1.setText(b2+"");
check.holdDVal(b2);}
else if (i==2){
d2.setText(b2+"");
check.holdDVal(b2);}
else if (i==3){
d3.setText(b2+"");
check.holdDVal(b2);}
else if (i==4){
d4.setText(b2+"");
check.holdDVal(b2);}
else if (i==4){
d5.setText(b2+"");
check.holdDVal(b2);}
}
dealersTurn=check.getDVal();
JOptionPane.showMessageDialog(null,"Dealer's Roll Value: "+dealersTurn);
//
if (dealersTurn>=catcher && dealersTurn<14){
JOptionPane.showMessageDialog(null,"Dealer Wins!");
Earnings=Earnings-yourBet;
jTextField3.setText(Earnings+"");
totalMoney=totalMoney+Earnings;
// totalMoney=totalMoney-yourBet;
jTextField4.setText(totalMoney+"");
playon.setEnabled(true);
}
else
JOptionPane.showMessageDialog(null,"You Win!");
{Earnings=Earnings+yourBet;
jTextField3.setText(Earnings+"");
totalMoney=totalMoney+Earnings+yourBet;
jTextField4.setText(totalMoney+"");
playon.setEnabled(true);
}
// Make a frame to show the Winner
}
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(dicegame13.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(dicegame13.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(dicegame13.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(dicegame13.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new dicegame13().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton d1;
private javax.swing.JButton d2;
private javax.swing.JButton d3;
private javax.swing.JButton d4;
private javax.swing.JButton d5;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JButton playon;
private javax.swing.JButton stayButton;
// End of variables declaration
}
Here's the code for the class:
/*
* 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.
*/
package dicegame;
/**
*
* @author USER
*/
public class verify {
private int value1=0,value2=0,value3=0,value4=0,value5=0,Dval=0;
private int finalvalue;
//HOLDS THE VALUE
public void holdValue1(int x){
value1=x;
}
public void holdValue2(int x){
value2=x;
}
public void holdValue3(int x){
value3=x;
}
public void holdValue4(int x){
value4=x;
}
public void holdValue5(int x){
value5=x;
}
public void holdDVal(int x){
if(x==0)
Dval=0;
else
Dval+=x;
}
//GETS THE VALUE
public int getDVal(){
return Dval;
}
public int getValue1(){
return value1;
}
public int getValue2(){
return value2;
}
public int getValue3(){
return value3;
}
public int getValue4(){
return value4;
}
public int getValue5(){
return value5;
}
//ADDS THE VALUES
public int adder(){
finalvalue=value1+value2+value3+value4+value5;
return finalvalue;
}
}