id
stringlengths 36
36
| text
stringlengths 1
1.25M
|
---|---|
578fb02e-88ff-4ca6-8556-d86f65915ffa
|
public String getColor() {
return this.color;
}
|
27e259d4-72ed-4b9c-9caf-2ef7f64ba642
|
public void setColor(String color) {
this.color = color;
}
|
34bbbe4f-e2aa-4949-bf3c-6be6f2eaf64c
|
public int getValue() {
return value;
}
|
af279ca4-10c1-41a4-b2e2-f2003006d5dd
|
public void setValue(int value) {
this.value = value;
}
|
352b4408-4100-4b23-9a77-40f70af97c86
|
public Talon()
{
cartes = new LinkedList<Card>();
}
|
282da5a6-08b4-4d74-946d-d37bb8f5f225
|
public List<Card> getCartes() {
return cartes;
}
|
6b499bdd-ab3c-4dcb-9ae0-09af640e3ca6
|
public void setCartes(List<Card> cartes) {
this.cartes = cartes;
}
|
921f0ec1-a853-455a-a948-9b809960cc0e
|
public CartePasseTour(String color, int value)
{
super(color, value);
// this.color = color;
// this.value = value;
this.type = "Carte Passe ton tour";
}
|
94c8ba00-7ea2-44b0-a760-7ed43be1b692
|
public String getColor() {
return this.color;
}
|
8cba3297-0ca1-4f9e-b4c8-8d2f063cde8c
|
public void setColor(String color) {
this.color = color;
}
|
29639e53-c380-4dd3-ae48-7ba59945747a
|
public int getValue() {
return value;
}
|
f5a0758f-ac39-4592-8f7e-0c9ad27dc8fe
|
public void setValue(int value) {
this.value = value;
}
|
a52dd456-d446-4a3c-9ed4-220d1220308b
|
public CarteInverse(String color, int value)
{
super(color, value);
// this.color = color;
// this.value = value;
this.type = "Carte Inverse";
}
|
83ed6ee6-5381-4c5a-9c29-c0f3d42a0cc8
|
public String getColor() {
return this.color;
}
|
5b9e6e61-a6b8-49ca-9b20-73d0e44107ed
|
public void setColor(String color) {
this.color = color;
}
|
2096f2a6-53bf-4ebb-b5d8-7040db832518
|
public int getValue() {
return value;
}
|
d6be2591-a263-4af4-aa89-f0bdbfdce058
|
public void setValue(int value) {
this.value = value;
}
|
84e798c4-2873-4d20-b90b-8608d2ec607a
|
public CarteCouleur(String color, int value)
{
super(color, value);
// this.color = color;
// this.value = value;
this.type = "Carte normale";
}
|
dada71e6-c285-42bf-8a03-42928d7dd08a
|
public String getColor() {
return this.color;
}
|
cf1a047c-7a6c-4b0b-a0c6-da070374bfd0
|
public void setColor(String color) {
this.color = color;
}
|
47039922-7b55-4805-8f77-ebc1c375da34
|
public int getValue() {
return value;
}
|
a2b53ca3-2948-4b39-9df1-661a21dfe697
|
public void setValue(int value) {
this.value = value;
}
|
e6a774c0-f5df-4459-9d7a-9755d42e5e0e
|
public CarteJoker()
{
super("Black", 50);
this.type = "Carte Joker";
}
|
6e6d700c-5c71-4a9b-bc47-01e7481c5519
|
public String getColor() {
return this.color;
}
|
64487589-e7ae-4725-9da5-760febfedc17
|
public void setColor(String color) {
this.color = color;
}
|
bb8bcdaf-ccc5-45b0-80d4-d98ca5edb825
|
public int getValue() {
return value;
}
|
c571cab1-b8f4-4c78-b542-aaa69daf89c1
|
public void setValue(int value) {
this.value = value;
}
|
84f0fc4a-4827-4de7-975d-cd579f5ff0a2
|
public static void main(String[] args)
{
int nombreHumain;
int nombreJoueur;
Scanner sc = new Scanner(System.in);
// Scanner sc2 = new Scanner(System.in);
Jeu partieDeUNO;
System.out.print("Bienvenue dans le jeu de UNO\n\n");
System.out.print("Combien de joueur (humain + IA) ?");
nombreJoueur = sc.nextInt();
System.out.print("Combien de joueur humain ?");
nombreHumain = sc.nextInt();
// System.out.print("String ?\n");
// String s = sc2.nextLine();
//sc.close();
// sc2.close();
// System.out.println(s + "\n\n");
partieDeUNO = new Jeu(nombreJoueur, nombreHumain);
partieDeUNO.lancerManche();
}
|
5eccdebe-9c40-4910-9c30-198ef8d83292
|
public Joueur(String nom, Jeu partie)
{
poigne = new LinkedList<Card>();
score = 0;
this.nom = nom;
this.partie = partie;
aDitUNO = false;
}
|
8734b126-a57f-442a-aff2-e651599df444
|
public LinkedList getPoigne() {
return poigne;
}
|
0f43d399-5202-4b37-b7e5-e2e8a1f7ff80
|
public void setPoigne(LinkedList poigne) {
this.poigne = poigne;
}
|
a169ebe8-b73e-441f-b847-71dbe35ce8a6
|
public int getScore() {
return score;
}
|
4e98e2a6-d97d-4574-ad8e-ab2ff91be82c
|
public void setScore(int score) {
this.score = score;
}
|
3f39a3a9-14b7-4382-8234-1ec15dc1eadd
|
public String getNom() {
return nom;
}
|
defeb0b7-a4b3-46fd-a37b-5bc1dea533c7
|
public void afficherCartes()
{
int i = 0;
ListIterator<Card> li = poigne.listIterator();
while(li.hasNext())
{
System.out.println("Carte No" + i);
((Card)(li.next())).affichageCarte();
i++;
}
}
|
80b167ec-3705-4c19-af46-871c87c8adf2
|
public boolean estJouable(Card carte)
{
if((partie.getTalon().getCartes().get(0).getColor() == carte.getColor())||
(partie.getTalon().getCartes().get(0).getValue()== carte.getValue()))
return true;
if (carte.getColor() == "black")
return true;
return false;
}
|
15a36795-bfc0-4bc9-b024-bf4f4873472c
|
public void affichageTexte()
{
System.out.print("Joueur : " + nom + "\n" );
afficherCartes();
}
|
6fd6e43e-3203-4c74-8b87-635deefe04f8
|
public void jouer()
{
int reponse;
Scanner sc = new Scanner(System.in);
System.out.println("ca marche pas!\n");
System.out.println("Vos cartes : \n");
System.out.println("\nQuelle carte souhaitez vous jouer ?\n");
reponse = sc.nextInt();
}
|
a125c843-e1f4-4561-8fd6-130434b29076
|
public String getColor() {
return color;
}
|
7d3366fb-7bb4-463a-b6b0-493946a46fbe
|
public void setColor(String color) {
this.color = color;
}
|
174c2e1d-b433-47b9-bfee-a97c50e3f448
|
public int getValue() {
return value;
}
|
6f48e1d3-edbb-4bb7-8065-02f9e7d84d8a
|
public void setValue(int value) {
this.value = value;
}
|
80deeb57-3991-4876-a766-f46023ebb9b8
|
public Card(String color, int value)
{
this.color = color;
this.value = value;
}
|
8c35d1b3-0774-48a2-8992-4c7b3c83af93
|
public void affichageCarte()
{
System.out.print(type + " - " + color + " - " + value + "\n");
}
|
9c8bdefc-43ea-4382-bd5d-b7ec7af07258
|
public JoueurHumain(String nom, Jeu partie)
{
super(nom, partie);
}
|
2d95de77-66fe-4fc7-b623-19abfbafc7b8
|
public void selectionnerCarte()
{
affichageTexte();
}
|
c0e1b985-c93f-4dca-bb49-b9d9021d1ce9
|
public boolean poserCarte(int index)
{
if(estJouable(poigne.get(index)));
{
//partie.setPioche(pioche);
return false;
}
}
|
027a4c9b-bea8-40b6-a34d-356ccf2f7a17
|
public void jouer()
{
Scanner sc = new Scanner(System.in);
int reponse;
System.out.println("Quelle action voulez vous effectuer ?\n");
System.out.println("- 1 ) Jouer une carte ?\n");
System.out.println("- 2 ) Piocher une carte \n");
System.out.println("- 3 ) Dire UNO \n");
System.out.println("- 4 ) Dire contre-UNO \n");
reponse = sc.nextInt();
switch(reponse)
{
case(1) :
System.out.println("- 1 ) Quelle carte souhaitez vous jouer ?\n");
afficherCartes();
Scanner sc2 = new Scanner(System.in);
// while(!poserCarte(sc2.next()))
// {
// }
//
case(2):
poigne.add((Card)(partie.getPioche().getToutesLesCartes().poll()));
case(3):
aDitUNO = true;
}
}
|
4be121f8-efa9-4957-b9bf-e4d26dcec06a
|
public CarteSuperJoker()
{
super("Black", 50);
this.type = "Carte +4";
}
|
b9d4c50e-4743-423e-b0be-2fc9abd882dd
|
public String getColor() {
return this.color;
}
|
70bef6f0-5937-413b-aab5-1d0af9a07483
|
public void setColor(String color) {
this.color = color;
}
|
373f5e19-abd2-4fe9-8485-3bff23630c75
|
public int getValue() {
return value;
}
|
193bafe6-25ab-4d47-8a75-76f8974989c1
|
public void setValue(int value) {
this.value = value;
}
|
a3d2400e-721f-4e56-918a-cb930b15125d
|
public GenericStack_array(int size){
tarray = (T[]) new Object[size];
}
|
191b0c43-2c6c-4a83-9fbd-3f9c0eb96b2c
|
public void push(T item){
if(position == tarray.length){
System.out.println("array size increasing");
T[] temparray = (T[]) new Object[(tarray.length*2)];
for(int i=0; i<position; i++){
temparray[i] = tarray[i];
}
tarray = temparray;
}
tarray[position] = item;
position++;
}
|
da1566a3-f7f6-4e9c-8b55-1dfd71700d7d
|
public Object pop(){
position--;
Object result = tarray[position];
if(position < (tarray.length/4)){
System.out.println("array size decreasing");
T[] temparray = (T[]) new Object[(tarray.length/2)];
for(int i=0; i<position; i++){
temparray[i] = tarray[i];
}
tarray = temparray;
}
return result;
}
|
9385fdb4-b158-413a-9e76-82d72019ed3d
|
public boolean isEmpty(){
if(position == 0)
return true;
return false;
}
|
41917da2-93e3-4035-80fc-cd8b2408fd35
|
public int size(){
return position;
}
|
2eca5c23-df64-4ad1-85ee-00c422190f3d
|
public Node(T item, Node next){
this.item = item;
this.next = next;
}
|
37915ed2-1b44-4ce3-ac29-a5d1d1fac0c5
|
public void push(T stringarray){
first = new Node(stringarray,first);
N++;
}
|
90ab7eba-a7a0-48c7-93d5-689d1e8bb133
|
public T pop(){
T result = first.item;
first = first.next;
N--;
return result;
}
|
46160462-e2b9-4db9-bfd6-4dc4113d77d5
|
public boolean isEmpty(){
if(N==0)
return true;
return false;
}
|
b82ad90d-6af3-45cc-9c8c-75ff2f54ce60
|
public int size(){
return N;
}
|
2ecce73b-096c-4d13-86f4-320d12024866
|
public static void main(String[] args) {
object_array();
System.out.println("###########################");
object_linkedlist();
}
|
3b0a73d9-3ebf-4425-bfc2-d1497d3c63bd
|
private static void object_array(){
int testsize = 11;
//Integer part
GenericStack_array<Integer> intarray = new GenericStack_array<Integer>(testsize);
for(int i = 0; i < testsize; i++){
intarray.push(i);
System.out.println("position = "+intarray.position+" ; Value = "+i);
}
System.out.println("-------------------------------------");
for(int i = 0; i < testsize; i++){
Object result = intarray.pop();
System.out.println("position = "+intarray.position+" ; Value = "+result);
}
System.out.println("##-------------------------------------##");
//String part
GenericStack_array<String> stringarray = new GenericStack_array<String>(testsize);
for(int i = 0; i < testsize; i++){
stringarray.push("string"+i);
System.out.println("position = "+stringarray.position+" ; Value = "+i);
}
System.out.println("-------------------------------------");
for(int i = 0; i < testsize; i++){
Object result = stringarray.pop();
System.out.println("position = "+stringarray.position+" ; Value = "+result);
}
}
|
c923f5f3-abd1-43d3-8e67-7eda52051de8
|
private static void object_linkedlist(){
//Integer part
int[] intarray = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
GenericStack_linkedlist<Integer> intnode = new GenericStack_linkedlist<Integer>();
for(int i=0; i<intarray.length; i++){
System.out.println("Node item = "+intnode.N+" ;");
intnode.push(intarray[i]);
}
System.out.println("-------------------------------------");
for(int i=0; i<intarray.length; i++){
Object result = intnode.pop();
System.out.println("Node item = "+intnode.N+" ; Value = "+result);
}
System.out.println("##-------------------------------------##");
//String part
String[] stringarray = {"test0","test1"};
GenericStack_linkedlist<String> stringnode = new GenericStack_linkedlist<String>();
for(int i=0; i<stringarray.length; i++){
System.out.println("Node item = "+stringnode.N+" ;");
stringnode.push(stringarray[i]);
}
System.out.println("-------------------------------------");
for(int i=0; i<stringarray.length; i++){
Object result = stringnode.pop();
System.out.println("Node item = "+stringnode.N+" ; Value = "+result);
}
}
|
d3c58b36-2483-4381-aec9-7f2adafbe399
|
public static void main(String [] args) {
try {
byte[] encoded = Files.readAllBytes(Paths.get("textfile.txt"));
filestring = new String(encoded,Charset.defaultCharset());
words = filestring.split("[-!~\\s]+");
for(String word : words){
uniquewords.add(word);
}
System.out.println("Number of Words: "+uniquewords.size());
}catch(Exception e){
e.printStackTrace();
}
}
|
668e201c-5b0d-4a7b-8d14-ebb253ec968f
|
public static void main(String [] args) {
try {
byte[] encoded = Files.readAllBytes(Paths.get("textfile.txt"));
filestring = new String(encoded, Charset.defaultCharset());
words = filestring.split("[-!~\\s]+");
for(String word : words){
if(uniquewords.containsKey(word)){
uniquewords.put(word,uniquewords.get(word).intValue()+1);
}else{
uniquewords.put(word,1);
}
}
System.out.println("Number of Words: "+uniquewords.size());
Iterator it = uniquewords.entrySet().iterator();
while(it.hasNext()){
Map.Entry pairs = (Map.Entry) it.next();
System.out.println(pairs.getKey() + " " + pairs.getValue());
it.remove();
}
}catch(Exception e){
e.printStackTrace();
}
}
|
2710aceb-a50e-40d5-b5c5-8ba19a27f401
|
public static void main(String[] args) {
List<String> numberslist = new ArrayList<String>(Arrays.asList(args));
Collections.sort(numberslist);
System.out.println("Maximum: "+maximum(numberslist));
System.out.println("Median: "+median(numberslist));
System.out.println("StandardDeviation: "+standard_deviation(numberslist));
}
|
bcdf57ec-3ae8-42b9-a5c4-744983cb3cd3
|
private static String maximum(List<String> numberslist){
return numberslist.get(numberslist.size() - 1);
}
|
cd6bf518-8a27-4bdb-a512-bb6686851df2
|
private static String median(List<String> numberslist){
String result = null;
if(numberslist.size()%2==0){
int middle = numberslist.size() / 2;
int middleright = Integer.parseInt(numberslist.get(middle));
int middleleft = Integer.parseInt(numberslist.get(middle - 1));
result = Integer.toString((middleright + middleleft)/2);
}else{
result = numberslist.get(numberslist.size()/2);
}
return result;
}
|
80ff01a4-62f7-47eb-bf6b-ccc9d31aa145
|
private static String standard_deviation(List<String> numberslist){
int total = 0;
for(int i=0; i<numberslist.size(); i++){
total += Integer.parseInt(numberslist.get(i));
}
//wrong?
String result = Integer.toString(total/numberslist.size());
return result;
}
|
88c88c36-5ddc-46d9-89e7-4576c515710d
|
public static void main(String[] args) throws IOException, InterruptedException{
String searchterm = null;
int snippetlength = 2;
if(args.length > 1){
searchterm = args[0];
if(Integer.parseInt(args[1])>=0)
snippetlength = Integer.parseInt(args[1]);
}else{
System.out.println("Not enough arguments entered! Usage: Search Term, Snippet ");
return;
}
System.err.println(">WARNING!!, results not 'trustworthy'");
// System.out.println(">>ArrayList");
// for(int i = 0; i < RUN_TIMES; i++) {
// double processtime = algorithmList(new ArrayList<String>(), 2^i, searchterm, snippetlength);
// System.out.println((2^i) + "\t" + processtime);
// }
// System.out.println(">>LinkedList");
// for(int i = 0; i < RUN_TIMES; i++) {
// double processtime = algorithmList(new LinkedList<String>(), 2^i, searchterm, snippetlength);
// System.out.println("plot(" + (2^i) + "," + processtime + ",'-or');");
// }
System.out.println(">>Vector");
for(int i = 0; i < RUN_TIMES; i++) {
double processtime = algorithmList(new Vector<String>(), 2^i, searchterm, snippetlength);
System.out.println((2^i) + "\t" + processtime);
}
}
|
46cf2cd3-7830-4e73-8273-cbec052331ca
|
public static double algorithmList(List<String> wordlist, int times_file, String searchterm, int snippetlength) throws IOException{
/*
*
*/
Stopwatch timer = new Stopwatch();
for(int i = 0; i < times_file; i++){
BufferedReader br = new BufferedReader(new FileReader(FILENAME));
String line = null;
while ((line = br.readLine()) != null) {
for (String word : line.split("[-!~\\s]+")) {
wordlist.add(word);
}
}
}
//double time = timer.elapsedTime();
//System.out.print(">>>> " + wordlist.getClass().getName());
//System.out.printf(" : [Words processed: %d |Time elapsed: %.3f ]\n",wordlist.size(),time);
/*
* N
*/
int position = 0;
int results =0;
//Stopwatch timer2 = new Stopwatch();
for(String word : wordlist) {
if (word.equals(searchterm)) {
StringBuilder temp = new StringBuilder();
for (int i = (position - snippetlength); i < (position + snippetlength + 1); i++) {
temp.append(wordlist.get(i)); //[http://programcreek.com/2013/03/arraylist-vs-linkedlist-vs-vector/]
temp.append(" ");
}
//System.out.println(">> "+ temp);
results++;
}
position++;
}
//double time2 = timer2.elapsedTime();
return timer.elapsedTime();
//System.out.printf(">> algorithm finished: [Results found: %d |Time elapsed: %.3f]\n\n",results,time2);
}
|
4ef48819-d239-4d11-95d9-5e60d01eabe5
|
public static void main(String[] args) {
String searchterm = "a-wringing";
try {
Stopwatch timer = new Stopwatch();
LinearProbingHashST<String, Integer> st = new LinearProbingHashST<String, Integer>();
byte[] encoded = Files.readAllBytes(Paths.get("dickens.txt"));
String filestring = new String(encoded, Charset.defaultCharset());
String[] words = filestring.split("[!~\\s]+");
for(int i = 0; i < words.length; i++){
st.put(words[i],i+1);
}System.out.println("size: "+st.size());
double time = timer.elapsedTime();
Stopwatch timer2 = new Stopwatch();
System.out.println("Result: "+st.get(searchterm)+" "+searchterm);
double time2 = timer2.elapsedTime();
System.out.printf("Processing file: %.3f sec| Get result: %.3f sec",time,time2);
}catch(Exception e){
e.printStackTrace();
}
}
|
c5684606-b3ee-47e8-b590-3aa2fe5933ad
|
public static void main(String[] args) {
String searchterm = "a-wringing";
try {
Stopwatch timer = new Stopwatch();
SeparateChainingHashST<String, Integer> st = new SeparateChainingHashST<String, Integer>();
byte[] encoded = Files.readAllBytes(Paths.get("dickens.txt"));
String filestring = new String(encoded, Charset.defaultCharset());
String[] words = filestring.split("[!~\\s]+");
for(int i = 0; i < words.length; i++){
st.put(words[i],i+1);
}System.out.println("size: "+st.size());
double time = timer.elapsedTime();
Stopwatch timer2 = new Stopwatch();
System.out.println("Result: "+st.get(searchterm)+" "+searchterm);
double time2 = timer2.elapsedTime();
System.out.printf("Processing file: %.3f sec| Get result: %.3f sec",time,time2);
}catch(Exception e){
e.printStackTrace();
}
}
|
cfe99210-0c22-4fb9-aa98-f43f58a2c49e
|
public Node(int item, Node next){
this.item = item;
this.next = next;
}
|
7ea08208-e637-4e9f-be52-9325fa7f3f97
|
public void push(int item){
first = new Node(item,first);
N++;
}
|
e48570d4-a1bc-4b1e-8c07-401b3ddebfc8
|
public int pop(){
int result = first.item;
first = first.next;
N--;
return result;
}
|
40a8e345-35e4-4b9c-a968-97aace3d0aff
|
public boolean isEmpty(){
if(N==0)
return true;
return false;
}
|
802b3a4d-9cf9-403d-87bb-2268d3e78d1f
|
public int size(){
return N;
}
|
0e9be8f1-8ae6-4e78-aa91-92d5bdf4d411
|
public static void main(String[] args) {
ints_array();
ints_linkedlist();
}
|
5a19f23e-ceb3-4b94-8bc1-63e2a97add33
|
private static void ints_array(){
StackOfInts_array intarray = new StackOfInts_array(testsize);
for(int i = 0; i < testsize; i++){
intarray.push(i);
System.out.println("position = "+intarray.position+" ; Value = "+i);
}
System.out.println("-------------------------------------");
for(int i = 0; i < testsize; i++){
int result = intarray.pop();
System.out.println("position = "+intarray.position+" ; Value = "+result);
}
}
|
56e6934c-a6da-40e1-98a2-dbb8b609c263
|
private static void ints_linkedlist(){
int[] intarray = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
StackOfInts_linkedlist intnode = new StackOfInts_linkedlist();
for(int i=0; i<intarray.length; i++){
System.out.println("Node item = "+intnode.N+" ;");
intnode.push(intarray[i]);
}
System.out.println("-------------------------------------");
for(int i=0; i<intarray.length; i++){
int result = intnode.pop();
System.out.println("Node item = "+intnode.N+" ; Value = "+result);
}
}
|
1037d913-682b-4263-bae6-92481fa6b3c6
|
public StackOfInts_array(int size){
intarray = new int[size];
}
|
b2f7d4f5-11f5-4378-9587-f7f2df611aa0
|
public void push(int item){
if(position == intarray.length){
System.out.println("array size increasing");
int[] temparray = new int[(intarray.length*2)];
for(int i=0; i<position; i++){
temparray[i] = intarray[i];
}
intarray = temparray;
}
intarray[position] = item;
position++;
}
|
25aa4f06-04f9-4527-b4e0-2e299e7fff38
|
public int pop(){
position--;
int result = intarray[position];
if(position < (intarray.length/4)){
System.out.println("array size decreasing");
int[] temparray = new int[(intarray.length/2)];
for(int i=0; i<position; i++){
temparray[i] = intarray[i];
}
intarray = temparray;
}
return result;
}
|
29c4d7fc-f243-4698-9332-c645cd1e3195
|
public boolean isEmpty(){
if(position == 0)
return true;
return false;
}
|
c43403ad-272f-4901-8cd4-d4137f96edf5
|
public int size(){
return position;
}
|
638924bb-8506-47e8-8d34-ed9ee9c3f10b
|
public Yhdistelma(Jatsikasi k){
super(k);
pisteet = 0;
nimi = null;
Arrays.sort(nopat); // Järjestetään nopat nousevaan järjestykseen
}
|
4b3a2cc5-783d-4143-8c77-e06f11eb3ce2
|
public Yhdistelma(Noppa[] n, int a, Jatsiyhdistelma b){
super(n);
pisteet = a;
nimi = b;
Arrays.sort(nopat); // Järjestetään nopat nousevaan järjestykseen
}
|
09a1da4d-a5b1-4c9d-85c4-cd23121a413d
|
public ArrayList<Yhdistelma> getYhdistelmat(){
ArrayList<Yhdistelma> a = new ArrayList<Yhdistelma>();
int points=0;
if(ykkoset()){
for(int i=0; i<5; i++){
if (nopat[i].getValue()==1){
points++;
}
}
a.add(new Yhdistelma(nopat, points, Jatsiyhdistelma.YKKOSET));
points=0;
}
if(kakkoset()){
for(int i=0; i<5; i++){
if (nopat[i].getValue()==2){
points++;
}
}
points = points*2;
a.add(new Yhdistelma(nopat, points, Jatsiyhdistelma.KAKKOSET));
points=0;
}
if(kolmoset()){
for(int i=0; i<5; i++){
if (nopat[i].getValue()==3){
points++;
}
}
points = points*3;
a.add(new Yhdistelma(nopat, points, Jatsiyhdistelma.KOLMOSET));
points=0;
}
if(neloset()){
for(int i=0; i<5; i++){
if (nopat[i].getValue()==4){
points++;
}
}
points = points*4;
a.add(new Yhdistelma(nopat, points, Jatsiyhdistelma.NELOSET));
points=0;
}
if(viitoset()){
for(int i=0; i<5; i++){
if (nopat[i].getValue()==5){
points++;
}
}
points = points*5;
a.add(new Yhdistelma(nopat, points, Jatsiyhdistelma.VIITOSET));
points=0;
}
if(kuutoset()){
for(int i=0; i<5; i++){
if (nopat[i].getValue()==6){
points++;
}
}
points = points*6;
a.add(new Yhdistelma(nopat, points, Jatsiyhdistelma.KUUTOSET));
points=0;
}
if(kaksiParia()){
int ind=0;
int tmpPoints;
for(int i=0; i<2; i++){
if(nopat[i].getValue()==nopat[i+1].getValue()){
ind = i+2;
points = nopat[i].getValue() + nopat[i+1].getValue();
break;
}
}
a.add(new Yhdistelma(nopat, points, Jatsiyhdistelma.PARI)); // add ensimmäinen pari
tmpPoints=points;
points=0;
for(int i=ind; i<4; i++){
if(nopat[i].getValue()==nopat[i+1].getValue()){
ind = i+2;
points = nopat[i].getValue() + nopat[i+1].getValue();
}
}
a.add(new Yhdistelma(nopat, points, Jatsiyhdistelma.PARI)); // add toinen pari
tmpPoints=tmpPoints+points;
points=0;
a.add(new Yhdistelma(nopat, tmpPoints, Jatsiyhdistelma.KAKSI_PARIA)); // add kaksi paria
}
else if(pari() || kolmeSamaa() || neljaSamaa()){ // Löytyy vain yksi pari
for(int i=0; i<4; i++){
if (nopat[i].getValue()==nopat[i+1].getValue()){
points = nopat[i].getValue() + nopat[i+1].getValue();
}
}
a.add(new Yhdistelma(nopat, points, Jatsiyhdistelma.PARI));
points=0;
}
if(kolmeSamaa() || neljaSamaa()){
for(int i=0; i<3; i++){
if (nopat[i].getValue()==nopat[i+1].getValue() && nopat[i].getValue()==nopat[i+2].getValue()){
points = nopat[i].getValue() + nopat[i+1].getValue() + nopat[i+2].getValue();
}
}
a.add(new Yhdistelma(nopat, points, Jatsiyhdistelma.KOLME_SAMAA));
points=0;
}
if(neljaSamaa()){
for(int i=0; i<2; i++){
if (nopat[i].getValue()==nopat[i+1].getValue() && nopat[i].getValue()==nopat[i+2].getValue() && nopat[i].getValue()==nopat[i+3].getValue()){
points = nopat[i].getValue() + nopat[i+1].getValue() + nopat[i+2].getValue() + nopat[i+3].getValue();
}
}
a.add(new Yhdistelma(nopat, points, Jatsiyhdistelma.NELJA_SAMAA));
points=0;
}
if(pikkusuora()){
a.add(new Yhdistelma(nopat, 15, Jatsiyhdistelma.PIKKUSUORA));
}
if(isosuora()){
a.add(new Yhdistelma(nopat, 20, Jatsiyhdistelma.ISOSUORA));
}
if(tayskasi()){
for(int i=0; i<5; i++){
points=points+nopat[i].getValue();
}
a.add(new Yhdistelma(nopat, points, Jatsiyhdistelma.TAYSKASI));
points=0;
}
// Sattuma
for(int i=0; i<5; i++){
points=points+nopat[i].getValue();
}
a.add(new Yhdistelma(nopat, points, Jatsiyhdistelma.SATTUMA));
points=0;
if(yatzy()){
a.add(new Yhdistelma(nopat, 50, Jatsiyhdistelma.YATZY));
}
return a;
}
|
bd3d6b7d-8b11-4ccf-a7f6-a84664e1e2a1
|
public boolean ykkoset(){
if(nopat[0].getValue()==1){
return true;
}
return false;
}
|
33b066e5-8d76-4685-9c02-602cc91b2dd8
|
public boolean kakkoset(){
for(int i=0; i<5; i++){
if(nopat[i].getValue()==2){
return true;
}
}
return false;
}
|
9509759c-b38d-4c83-b46b-a39c7a98835c
|
public boolean kolmoset(){
for(int i=0; i<5; i++){
if(nopat[i].getValue()==3){
return true;
}
}
return false;
}
|
6b93f068-9fdb-4015-86ae-adabcd68c0d2
|
public boolean neloset(){
for(int i=0; i<5; i++){
if(nopat[i].getValue()==4){
return true;
}
}
return false;
}
|
2efaaac1-54e0-4ed6-a24d-50443556c4a5
|
public boolean viitoset(){
for(int i=0; i<5; i++){
if(nopat[i].getValue()==5){
return true;
}
}
return false;
}
|
b3e3da39-d044-4a5b-bdf8-9de0a285777c
|
public boolean kuutoset(){
for(int i=0; i<5; i++){
if(nopat[i].getValue()==6){
return true;
}
}
return false;
}
|
fbc4a07f-59d7-43ea-9c44-1c3c17d3ad5e
|
public boolean pari(){
for(int i=0; i<4; i++){
if(nopat[i].getValue()==nopat[i+1].getValue()){
return true;
}
}
return false;
}
|
992ac616-147d-407d-b84f-d9be58ad4f24
|
public boolean kaksiParia(){
int count = 0;
for(int i=0; i<4; i++){
if(nopat[i].getValue()==nopat[i+1].getValue()){
count++;
i++;
}
}
if(count==2){
return true;
}
return false;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.