Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
poker
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Emanuel Lugo
poker
Commits
cd75c322
Commit
cd75c322
authored
Apr 26, 2022
by
Emanuel Lugo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
errores resueltos en jugada
parent
daa0a7b0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
77 deletions
+77
-77
Carta.java
+28
-26
pokerGame.java
+49
-51
No files found.
Carta.java
View file @
cd75c322
public
class
Carta
{
public
class
Carta
{
public
String
valor
;
public
String
valor
;
public
String
palo
;
public
String
palo
;
public
Carta
()
{
public
Carta
(){
}
}
public
Carta
(
String
completo
)
public
Carta
(
String
completo
)
{
{
if
(
completo
.
charAt
(
0
)
==
'A'
)
if
(
completo
.
charAt
(
0
)
==
'A'
)
this
.
valor
=
"1"
;
this
.
valor
=
"1"
;
else
if
(
completo
.
charAt
(
0
)
==
'T'
)
this
.
valor
=
"10"
;
else
if
(
completo
.
charAt
(
0
)
==
'T'
)
else
if
(
completo
.
charAt
(
0
)
==
'J'
)
this
.
valor
=
"11"
;
this
.
valor
=
"10"
;
else
if
(
completo
.
charAt
(
0
)
==
'Q'
)
this
.
valor
=
"12"
;
else
if
(
completo
.
charAt
(
0
)
==
'J'
)
else
if
(
completo
.
charAt
(
0
)
==
'K'
)
this
.
valor
=
"13"
;
this
.
valor
=
"11"
;
else
this
.
valor
=
String
.
valueOf
(
completo
.
charAt
(
0
));
else
if
(
completo
.
charAt
(
0
)
==
'Q'
)
this
.
valor
=
"12"
;
else
if
(
completo
.
charAt
(
0
)
==
'K'
)
this
.
valor
=
"13"
;
else
this
.
valor
=
String
.
valueOf
(
completo
.
charAt
(
0
));
this
.
palo
=
String
.
valueOf
(
completo
.
charAt
(
1
));
this
.
palo
=
String
.
valueOf
(
completo
.
charAt
(
1
));
}
}
String
valorPalo
()
String
valorPalo
()
{
{
if
(
this
.
valor
.
equals
(
"1"
))
{
if
(
this
.
valor
.
equals
(
"1"
))
{
return
"A"
+
" "
+
this
.
palo
;
return
"A"
+
this
.
palo
;
}
else
if
(
this
.
valor
.
equals
(
"10"
))
{
return
"T"
+
" "
+
this
.
palo
;
}
else
if
(
this
.
valor
.
equals
(
"10"
))
{
}
else
if
(
this
.
valor
.
equals
(
"11"
))
{
return
"J"
+
" "
+
this
.
palo
;
return
"T"
+
this
.
palo
;
}
else
if
(
this
.
valor
.
equals
(
"12"
))
{
return
"Q"
+
" "
+
this
.
palo
;
}
else
if
(
this
.
valor
.
equals
(
"11"
))
{
}
else
if
(
this
.
valor
.
equals
(
"13"
))
{
return
"K"
+
" "
+
this
.
palo
;
return
"J"
+
this
.
palo
;
}
else
return
this
.
valor
+
" "
+
this
.
palo
;
}
else
if
(
this
.
valor
.
equals
(
"12"
))
{
return
"Q"
+
this
.
palo
;
}
else
if
(
this
.
valor
.
equals
(
"13"
))
{
return
"K"
+
this
.
palo
;
}
else
return
this
.
valor
+
this
.
palo
;
}
}
public
int
getValorInt
()
{
public
int
getValorInt
()
{
int
aux
=
Integer
.
parseInt
(
this
.
valor
);
int
aux
=
Integer
.
parseInt
(
this
.
valor
);
return
aux
;
return
aux
;
...
@@ -46,7 +51,4 @@ public class Carta {
...
@@ -46,7 +51,4 @@ public class Carta {
}
}
}
}
pokerGame.java
View file @
cd75c322
...
@@ -14,6 +14,10 @@ public class pokerGame {
...
@@ -14,6 +14,10 @@ public class pokerGame {
int
contadorValor
=
0
;
int
contadorValor
=
0
;
int
contadorPalo
=
0
;
int
contadorPalo
=
0
;
int
valorCarta
,
valorSgteCarta
,
aux
;
int
valorCarta
,
valorSgteCarta
,
aux
;
// COMPROBACIÓN DE CASOS DE CARTAS EN SECUENCIA - ESCALERA COLOR - ESCALERA -
// COLOR
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
// System.out.println(mano.get(i).getValorInt() + ": valor carta1");
// System.out.println(mano.get(i).getValorInt() + ": valor carta1");
// System.out.println(mano.get(i+1).getValorInt() + ": valor carta2");
// System.out.println(mano.get(i+1).getValorInt() + ": valor carta2");
...
@@ -24,21 +28,11 @@ public class pokerGame {
...
@@ -24,21 +28,11 @@ public class pokerGame {
aux
=
valorCarta
+
1
;
aux
=
valorCarta
+
1
;
if
(
aux
==
valorSgteCarta
)
if
(
aux
==
valorSgteCarta
)
contadorValor
++;
contadorValor
++;
System
.
out
.
println
(
"contador SECUENCIAL: "
+
contadorValor
);
System
.
out
.
println
(
"contador PALOSIGUALES: "
+
contadorPalo
);
}
/*
// corroborar contadores
* int contadorPalo = 0;
// System.out.println("contador SECUENCIAL: " + contadorValor);
* for (int i=0;i<4;i++) {
// System.out.println("contador PALOSIGUALES: " + contadorPalo);
* //System.out.println("PALO de la carta1: " +mano.get(i).getPalo());
}
* //System.out.println("PALO de la carta2: " +mano.get(i+1).getPalo());
* if (mano.get(i).palo.equals(mano.get(i+1).palo)) contadorPalo++ ; // CUENTA
* CUANTAS CARTAS SON DEL MISMO PALO
* System.out.println("contador PALOSIGUALES: " + contadorPalo);
* }
*
*/
if
(
contadorValor
==
3
&&
mano
.
get
(
0
).
getValorInt
()
==
1
&&
mano
.
get
(
4
).
getValorInt
()
==
13
)
{
if
(
contadorValor
==
3
&&
mano
.
get
(
0
).
getValorInt
()
==
1
&&
mano
.
get
(
4
).
getValorInt
()
==
13
)
{
return
resultado
=
"ESCALERA COLOR"
;
return
resultado
=
"ESCALERA COLOR"
;
...
@@ -51,7 +45,7 @@ public class pokerGame {
...
@@ -51,7 +45,7 @@ public class pokerGame {
return
resultado
=
"COLOR"
;
return
resultado
=
"COLOR"
;
}
}
// CASOS PARA POKER Y FULL
// CASOS PARA POKER Y FULL
- CARTAS DOBLES Y TRIOS
int
valoresIguales
=
0
;
int
valoresIguales
=
0
;
valoresIguales
=
0
;
valoresIguales
=
0
;
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
...
@@ -60,13 +54,16 @@ public class pokerGame {
...
@@ -60,13 +54,16 @@ public class pokerGame {
}
}
}
}
if
(
valoresIguales
==
3
&&
mano
.
get
(
3
).
getValorInt
()
!=
mano
.
get
(
4
).
getValorInt
())
{
if
((
valoresIguales
==
3
&&
mano
.
get
(
3
).
getValorInt
()
!=
mano
.
get
(
4
).
getValorInt
())
||
valoresIguales
==
3
&&
mano
.
get
(
0
).
getValorInt
()
!=
mano
.
get
(
1
).
getValorInt
())
{
return
resultado
=
"POKER"
;
return
resultado
=
"POKER"
;
}
else
if
((
valoresIguales
==
3
&&
mano
.
get
(
3
).
getValorInt
()
==
mano
.
get
(
4
).
getValorInt
())
}
else
if
((
valoresIguales
==
3
&&
mano
.
get
(
3
).
getValorInt
()
==
mano
.
get
(
4
).
getValorInt
())
||
(
valoresIguales
==
3
&&
mano
.
get
(
0
).
getValorInt
()
==
mano
.
get
(
1
).
getValorInt
()))
{
||
(
valoresIguales
==
3
&&
mano
.
get
(
0
).
getValorInt
()
==
mano
.
get
(
1
).
getValorInt
()))
{
return
resultado
=
"FULL"
;
return
resultado
=
"FULL"
;
}
else
if
((
valoresIguales
==
2
&&
mano
.
get
(
3
).
getValorInt
()
!=
mano
.
get
(
4
).
getValorInt
())
}
else
if
((
valoresIguales
==
2
&&
mano
.
get
(
3
).
getValorInt
()
!=
mano
.
get
(
4
).
getValorInt
()
||
(
valoresIguales
==
2
&&
mano
.
get
(
0
).
getValorInt
()
!=
mano
.
get
(
1
).
getValorInt
()))
{
&&
mano
.
get
(
1
).
getValorInt
()
==
mano
.
get
(
3
).
getValorInt
())
||
(
valoresIguales
==
2
&&
mano
.
get
(
0
).
getValorInt
()
!=
mano
.
get
(
1
).
getValorInt
())
&&
mano
.
get
(
2
).
getValorInt
()
==
mano
.
get
(
4
).
getValorInt
())
{
return
resultado
=
"TRIO"
;
return
resultado
=
"TRIO"
;
}
}
...
@@ -81,55 +78,55 @@ public class pokerGame {
...
@@ -81,55 +78,55 @@ public class pokerGame {
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
Carta
carta1
,
carta2
,
carta3
,
carta4
,
carta5
;
ArrayList
<
Carta
>
mano
=
new
ArrayList
<
Carta
>();
pokerGame
poker
=
new
pokerGame
();
pokerGame
poker
=
new
pokerGame
();
String
resultado
;
String
resultado
;
int
i
;
int
i
;
Carta
carta1
,
carta2
,
carta3
,
carta4
,
carta5
;
carta1
=
new
Carta
(
"KS "
);
ArrayList
<
Carta
>
mano
=
new
ArrayList
<
Carta
>();
carta1
=
new
Carta
(
"6S "
);
carta2
=
new
Carta
(
"6C "
);
carta2
=
new
Carta
(
"6C "
);
carta3
=
new
Carta
(
"
KD
"
);
carta3
=
new
Carta
(
"
6H
"
);
carta4
=
new
Carta
(
"
A
D "
);
carta4
=
new
Carta
(
"
6
D "
);
carta5
=
new
Carta
(
"
AC
"
);
carta5
=
new
Carta
(
"
KC
"
);
mano
.
add
(
carta1
);
mano
.
add
(
carta1
);
mano
.
add
(
carta2
);
mano
.
add
(
carta2
);
mano
.
add
(
carta3
);
mano
.
add
(
carta3
);
mano
.
add
(
carta4
);
mano
.
add
(
carta4
);
mano
.
add
(
carta5
);
mano
.
add
(
carta5
);
/*
* for (i = 0; i < 5; i++) {
* System.out.println(mano.get(i).valorPalo());
* }
*/
for
(
i
=
0
;
i
<
mano
.
size
();
i
++)
System
.
out
.
println
(
mano
.
get
(
i
).
valorPalo
());
Collections
.
sort
(
mano
,
new
SortbyPalo
());
System
.
out
.
println
(
""
);
for
(
i
=
0
;
i
<
mano
.
size
();
i
++)
System
.
out
.
println
(
mano
.
get
(
i
).
valorPalo
());
Collections
.
sort
(
mano
,
new
SortbyValor
());
Collections
.
sort
(
mano
,
new
SortbyValor
());
System
.
out
.
print
(
"MANO: "
);
System
.
out
.
println
(
""
);
for
(
i
=
0
;
i
<
mano
.
size
();
i
++)
System
.
out
.
println
(
mano
.
get
(
i
).
valorPalo
());
Collections
.
sort
(
mano
,
new
SortbyValor
());
System
.
out
.
println
(
""
);
for
(
i
=
0
;
i
<
mano
.
size
();
i
++)
for
(
i
=
0
;
i
<
mano
.
size
();
i
++)
System
.
out
.
print
ln
(
mano
.
get
(
i
).
valorPalo
()
);
System
.
out
.
print
(
mano
.
get
(
i
).
valorPalo
()
+
" "
);
System
.
out
.
println
(
" "
);
resultado
=
poker
.
jugadas
(
mano
);
resultado
=
poker
.
jugadas
(
mano
);
System
.
out
.
println
(
resultado
);
System
.
out
.
println
(
resultado
);
}
}
}
}
/*
* PARA TESTEAR
* Collections.sort(mano, new SortbyPalo());
*
* System.out.println("");
*
* for (i = 0; i < mano.size(); i++)
* System.out.println(mano.get(i).valorPalo());
*
* Collections.sort(mano, new SortbyValor());
*
* System.out.println("");
*
* for (i = 0; i < mano.size(); i++)
* System.out.println(mano.get(i).valorPalo());
*
* Collections.sort(mano, new SortbyValor());
*
* System.out.println("");
*
* for (i = 0; i < mano.size(); i++)
* System.out.println(mano.get(i).valorPalo());
*/
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment