jrtec 8 years ago
parent
commit
ebc79591ab
4 changed files with 12 additions and 37 deletions
  1. +3
    -6
      src/net/jrtechs/setgame/Game.java
  2. +2
    -8
      src/net/jrtechs/setgame/Hand.java
  3. +1
    -5
      src/net/jrtechs/setgame/SetButton.java
  4. +6
    -18
      src/net/jrtechs/setgame/SetGame.java

+ 3
- 6
src/net/jrtechs/setgame/Game.java View File

@ -6,8 +6,8 @@ Game class keeps track of the score hand and deck
package net.jrtechs.setgame;
import java.awt.Color;//for colors of the buttons
import java.util.ArrayList; //for the arraylist
import java.awt.Color;
import java.util.ArrayList;
public class Game
{
@ -35,12 +35,9 @@ public class Game
timeOnSet = 0;
}
public void timerTic()
{
{
time++;
timeOnSet++;
}
public Card[] getHand()
{

+ 2
- 8
src/net/jrtechs/setgame/Hand.java View File

@ -15,11 +15,7 @@ public class Hand
int count = 0;
for(Card c: hand)
{
if(c == null)
{
//skip the null cards
}
else
if(c != null)
{
transfer[count] = c;
count++;
@ -37,12 +33,10 @@ public class Hand
}
public void display()
{
for(Card elem : hand)
System.out.print(elem + " ");
System.out.println("");
}
public Card[] getHand()
{

+ 1
- 5
src/net/jrtechs/setgame/SetButton.java View File

@ -33,11 +33,7 @@ public class SetButton extends JButton
}
public void update()
{
if(card == null)
{
//do nothing
}
else
if(card != null)
{
//sets the image of the button baised on its properties
//images located in the /src folder, file are named as a 4 digit number

+ 6
- 18
src/net/jrtechs/setgame/SetGame.java View File

@ -21,21 +21,15 @@ public class SetGame extends javax.swing.JFrame implements ActionListener
cmdFindSet.setEnabled(false);
cmdOpen3.setEnabled(false);
//creates an event listener for the timer
//creates an event listener for the timer in the game class
ActionListener actTimer = new ActionListener()
{
{
public void actionPerformed(ActionEvent e)
{
if(game == null)
{
}
else
if(game != null)
{
game.timerTic();
lblTime.setText("Time " + game.getTime());
}
}
};
@ -83,7 +77,6 @@ public class SetGame extends javax.swing.JFrame implements ActionListener
public void actionPerformed(ActionEvent e)
{
//System.out.println(e);
//casts the object of e to a setButton then calls the getLoc to find its index location in the cards "setButtons" array
SetButton clicked = (SetButton)e.getSource();
cards[clicked.getLoc()].clicked();
@ -182,19 +175,16 @@ public class SetGame extends javax.swing.JFrame implements ActionListener
lblSetsOnBoard.setText("Sets on board " + game.getSetsLeft());
if(game.getSetsLeft() == 0)
{
cmdFindSet.setEnabled(false);
endGame();
}
else if(game.getHand().length==12 && game.getDeck().cardsLeft() > 2)
{
cmdOpen3.setEnabled(true);
cmdOpen3.setEnabled(true);
}
}
private void cmdExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdExitActionPerformed
System.exit(-1);
System.exit(0);
}//GEN-LAST:event_cmdExitActionPerformed
private void endGame()
{
@ -206,9 +196,7 @@ public class SetGame extends javax.swing.JFrame implements ActionListener
{
game = null;
cmdOpen3.setEnabled(false);
JOptionPane.showMessageDialog(null,"There are no more sets left on the board.","End of Game",JOptionPane.WARNING_MESSAGE);
JOptionPane.showMessageDialog(null,"There are no more sets left on the board.","End of Game",JOptionPane.WARNING_MESSAGE);
}
}
private void cmdFindSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdFindSetActionPerformed

Loading…
Cancel
Save