Android Open Source - yahtzee4android Three Of A Kind Move






From Project

Back to project page yahtzee4android.

License

The source code is released under:

GNU General Public License

If you think the Android project yahtzee4android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.tum.yahtzee.moves;
//from ww  w .java  2 s.c  om
import java.util.List;

import com.tum.yahtzee.units.Cube;

public class ThreeOfAKindMove implements IBaseMove {
  private int points;
  
  public static boolean validate(List<Cube> cubes)
  {
    int[] values = new int[6];
    for(int i=0;i<6;i++) { values[i] = 0; }
    for(Cube cube : cubes) { values[cube.getNumber()]++; }
    
    for(int i=0;i<6;i++)
    {
      if (values[i] >= 3) return true;
    }
    return false;
  }
  
  public static int calculatePoints(List<Cube> cubes)
  {
    int points = 0;
    for(Cube cube : cubes)
    {
      points += cube.getNumber();
    }
    return points;
  }
  
  public ThreeOfAKindMove(List<Cube> cubes)
  {
    points = ThreeOfAKindMove.calculatePoints(cubes);
  }
  
  public int getPoints()
  {
    return points;
  }
  
  public void print()
  {
    System.out.println("ThreeOfAKind, Points: "+getPoints());
  }
}




Java Source Code List

com.tum.yahtzee.GameActivity.java
com.tum.yahtzee.GameController.java
com.tum.yahtzee.YahtzeeActivity.java
com.tum.yahtzee.listeners.OnCubeClickListener.java
com.tum.yahtzee.moves.ChanceMove.java
com.tum.yahtzee.moves.DummyMove.java
com.tum.yahtzee.moves.FourOfAKindMove.java
com.tum.yahtzee.moves.FullHouseMove.java
com.tum.yahtzee.moves.IBaseMove.java
com.tum.yahtzee.moves.LargeStraightMove.java
com.tum.yahtzee.moves.NumberMove.java
com.tum.yahtzee.moves.SmallStraightMove.java
com.tum.yahtzee.moves.ThreeOfAKindMove.java
com.tum.yahtzee.moves.YahtzeeMove.java
com.tum.yahtzee.services.MessageService.java
com.tum.yahtzee.services.MethodPointer.java
com.tum.yahtzee.units.Cube.java
com.tum.yahtzee.units.Player.java