Commit 67ea9ff4 authored by ignas's avatar ignas

--no commit message

--no commit message
parents
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>Dicegame</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="43" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="p1roll" alignment="0" min="-2" pref="73" max="-2" attributes="0"/>
<Component id="p1dice" alignment="0" min="-2" pref="103" max="-2" attributes="0"/>
</Group>
<EmptySpace min="60" pref="38" max="32767" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Component id="nextround" min="-2" pref="215" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="76" max="-2" attributes="0"/>
<Component id="p2roll" min="-2" pref="73" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="infoTF" min="-2" pref="252" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="32" max="-2" attributes="0"/>
<Component id="p2dice" min="-2" pref="102" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="67" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="231" max="-2" attributes="0"/>
<Component id="roundTF" min="-2" pref="154" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="roundTF" min="-2" pref="49" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="p1dice" alignment="3" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="p2dice" alignment="3" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="187" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="31" max="-2" attributes="0"/>
<Component id="infoTF" min="-2" pref="166" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="p1roll" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="p2roll" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="nextround" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="p1roll">
<Properties>
<Property name="text" type="java.lang.String" value="P1 Roll"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="p1rollActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="p2roll">
<Properties>
<Property name="text" type="java.lang.String" value="P2 Roll"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="p2rollActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="p1dice">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="48" style="1"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="p2dice">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="48" style="1"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="roundTF">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="24" style="1"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="Round 1"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="roundTFActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="nextround">
<Properties>
<Property name="text" type="java.lang.String" value="Next Round"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="nextroundActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="infoTF">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="infoTFActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>
import java.util.Random;
/*
* 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.
*/
/**
*
* @author ignas
*/
public class dice extends javax.swing.JFrame {
int p1_score = 0;
int p2_score = 0;
int round_counter = 1;
double p1rolls = 0;
double p2rolls =0;
double com = 0;
/**
* Creates new form dice
*/
public dice() {
initComponents();
}
/**
* 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">//GEN-BEGIN:initComponents
private void initComponents() {
p1roll = new javax.swing.JButton();
p2roll = new javax.swing.JButton();
p1dice = new javax.swing.JTextField();
p2dice = new javax.swing.JTextField();
roundTF = new javax.swing.JTextField();
nextround = new javax.swing.JButton();
infoTF = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
p1roll.setText("P1 Roll");
p1roll.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
p1rollActionPerformed(evt);
}
});
p2roll.setText("P2 Roll");
p2roll.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
p2rollActionPerformed(evt);
}
});
p1dice.setEditable(false);
p1dice.setBackground(new java.awt.Color(255, 255, 255));
p1dice.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
p1dice.setHorizontalAlignment(javax.swing.JTextField.CENTER);
p2dice.setEditable(false);
p2dice.setBackground(new java.awt.Color(255, 255, 255));
p2dice.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
p2dice.setHorizontalAlignment(javax.swing.JTextField.CENTER);
roundTF.setEditable(false);
roundTF.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
roundTF.setHorizontalAlignment(javax.swing.JTextField.CENTER);
roundTF.setText("Round 1");
roundTF.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
roundTFActionPerformed(evt);
}
});
nextround.setText("Next Round");
nextround.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nextroundActionPerformed(evt);
}
});
infoTF.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
infoTFActionPerformed(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(43, 43, 43)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(p1roll, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(p1dice, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(38, 38, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(nextround, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(76, 76, 76)
.addComponent(p2roll, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(infoTF, javax.swing.GroupLayout.PREFERRED_SIZE, 252, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32)
.addComponent(p2dice, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(67, 67, 67))
.addGroup(layout.createSequentialGroup()
.addGap(231, 231, 231)
.addComponent(roundTF, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(roundTF, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(p1dice, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(p2dice, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(187, 187, 187))
.addGroup(layout.createSequentialGroup()
.addGap(31, 31, 31)
.addComponent(infoTF, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(p1roll)
.addComponent(p2roll)
.addComponent(nextround))
.addGap(28, 28, 28))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void p1rollActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_p1rollActionPerformed
// a button for player one to roll the dice
Random rd=new Random();
int random=0;
random=rd.nextInt(6)+1;
switch(random){
case 1:
p1dice.setText("1");
break;
case 2:
p1dice.setText("2");
break;
case 3:
p1dice.setText("3");
break;
case 4:
p1dice.setText("4");
break;
case 5:
p1dice.setText("5");
case 6:
p1dice.setText("6");
break;
}
double p1 = Double.parseDouble(p1dice.getText());
p1rolls = p1rolls + p1;
com = com + p1rolls;
}//GEN-LAST:event_p1rollActionPerformed
private void p2rollActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_p2rollActionPerformed
// A button for player 2 to roll the dice
Random rd=new Random();
int random=0;
random=rd.nextInt(6)+1;
switch(random){
case 1:
p2dice.setText("1");
break;
case 2:
p2dice.setText("2");
break;
case 3:
p2dice.setText("3");
break;
case 4:
p2dice.setText("4");
break;
case 5:
p2dice.setText("5");
case 6:
p2dice.setText("6");
break;
}
double p2 = Double.parseDouble(p2dice.getText());
p2rolls =p2rolls + p2;
com = com + p2rolls;
}//GEN-LAST:event_p2rollActionPerformed
private void roundTFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_roundTFActionPerformed
}//GEN-LAST:event_roundTFActionPerformed
private void nextroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextroundActionPerformed
// TODO add your handling code here:
double p1 = Double.parseDouble(p1dice.getText());
double p2 = Double.parseDouble(p2dice.getText());
round_counter = round_counter +1;
p1dice.setText("");
p2dice.setText("");
String c = Double.toString(com);
infoTF.setText(c);
if (round_counter == 2){
roundTF.setText("Round 2");
}
if (round_counter == 3){
roundTF.setText("Round 3");
}
}//GEN-LAST:event_nextroundActionPerformed
private void infoTFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_infoTFActionPerformed
// the information text field
}//GEN-LAST:event_infoTFActionPerformed
/**
* @param args the command line arguments
*/
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(dice.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(dice.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(dice.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(dice.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 dice().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField infoTF;
private javax.swing.JButton nextround;
private javax.swing.JTextField p1dice;
private javax.swing.JButton p1roll;
private javax.swing.JTextField p2dice;
private javax.swing.JButton p2roll;
private javax.swing.JTextField roundTF;
// End of variables declaration//GEN-END:variables
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment