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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
87 deletions
+87
-87
Carta.java
+37
-35
pokerGame.java
+50
-52
No files found.
Carta.java
View file @
cd75c322
public
class
Carta
{
public
String
valor
;
public
String
palo
;
public
String
valor
;
public
String
palo
;
public
Carta
(){
}
public
Carta
(
String
completo
)
{
if
(
completo
.
charAt
(
0
)
==
'A'
)
this
.
valor
=
"1"
;
else
if
(
completo
.
charAt
(
0
)
==
'T'
)
this
.
valor
=
"10"
;
else
if
(
completo
.
charAt
(
0
)
==
'J'
)
this
.
valor
=
"11"
;
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
));
}
String
valorPalo
()
{
if
(
this
.
valor
.
equals
(
"1"
))
{
return
"A"
+
" "
+
this
.
palo
;
}
else
if
(
this
.
valor
.
equals
(
"10"
))
{
return
"T"
+
" "
+
this
.
palo
;
}
else
if
(
this
.
valor
.
equals
(
"11"
))
{
return
"J"
+
" "
+
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
Carta
()
{
}
public
Carta
(
String
completo
)
{
if
(
completo
.
charAt
(
0
)
==
'A'
)
this
.
valor
=
"1"
;
else
if
(
completo
.
charAt
(
0
)
==
'T'
)
this
.
valor
=
"10"
;
else
if
(
completo
.
charAt
(
0
)
==
'J'
)
this
.
valor
=
"11"
;
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
));
}
String
valorPalo
()
{
if
(
this
.
valor
.
equals
(
"1"
))
{
return
"A"
+
this
.
palo
;
}
else
if
(
this
.
valor
.
equals
(
"10"
))
{
return
"T"
+
this
.
palo
;
}
else
if
(
this
.
valor
.
equals
(
"11"
))
{
return
"J"
+
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
);
return
aux
;
...
...
@@ -46,7 +51,4 @@ public class Carta {
}
}
pokerGame.java
View file @
cd75c322
...
...
@@ -14,6 +14,10 @@ public class pokerGame {
int
contadorValor
=
0
;
int
contadorPalo
=
0
;
int
valorCarta
,
valorSgteCarta
,
aux
;
// COMPROBACIÓN DE CASOS DE CARTAS EN SECUENCIA - ESCALERA COLOR - ESCALERA -
// COLOR
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
// System.out.println(mano.get(i).getValorInt() + ": valor carta1");
// System.out.println(mano.get(i+1).getValorInt() + ": valor carta2");
...
...
@@ -24,21 +28,11 @@ public class pokerGame {
aux
=
valorCarta
+
1
;
if
(
aux
==
valorSgteCarta
)
contadorValor
++;
System
.
out
.
println
(
"contador SECUENCIAL: "
+
contadorValor
);
System
.
out
.
println
(
"contador PALOSIGUALES: "
+
contadorPalo
);
}
/*
* int contadorPalo = 0;
* for (int i=0;i<4;i++) {
* //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);
* }
*
*/
// corroborar contadores
// System.out.println("contador SECUENCIAL: " + contadorValor);
// System.out.println("contador PALOSIGUALES: " + contadorPalo);
}
if
(
contadorValor
==
3
&&
mano
.
get
(
0
).
getValorInt
()
==
1
&&
mano
.
get
(
4
).
getValorInt
()
==
13
)
{
return
resultado
=
"ESCALERA COLOR"
;
...
...
@@ -51,7 +45,7 @@ public class pokerGame {
return
resultado
=
"COLOR"
;
}
// CASOS PARA POKER Y FULL
// CASOS PARA POKER Y FULL
- CARTAS DOBLES Y TRIOS
int
valoresIguales
=
0
;
valoresIguales
=
0
;
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
...
...
@@ -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"
;
}
else
if
((
valoresIguales
==
3
&&
mano
.
get
(
3
).
getValorInt
()
==
mano
.
get
(
4
).
getValorInt
())
||
(
valoresIguales
==
3
&&
mano
.
get
(
0
).
getValorInt
()
==
mano
.
get
(
1
).
getValorInt
()))
{
return
resultado
=
"FULL"
;
}
else
if
((
valoresIguales
==
2
&&
mano
.
get
(
3
).
getValorInt
()
!=
mano
.
get
(
4
).
getValorInt
())
||
(
valoresIguales
==
2
&&
mano
.
get
(
0
).
getValorInt
()
!=
mano
.
get
(
1
).
getValorInt
()))
{
}
else
if
((
valoresIguales
==
2
&&
mano
.
get
(
3
).
getValorInt
()
!=
mano
.
get
(
4
).
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"
;
}
...
...
@@ -81,55 +78,55 @@ public class pokerGame {
}
public
static
void
main
(
String
[]
args
)
{
Carta
carta1
,
carta2
,
carta3
,
carta4
,
carta5
;
ArrayList
<
Carta
>
mano
=
new
ArrayList
<
Carta
>();
pokerGame
poker
=
new
pokerGame
();
String
resultado
;
int
i
;
Carta
carta1
,
carta2
,
carta3
,
carta4
,
carta5
;
ArrayList
<
Carta
>
mano
=
new
ArrayList
<
Carta
>();
carta1
=
new
Carta
(
"6S "
);
carta2
=
new
Carta
(
"6C "
);
carta3
=
new
Carta
(
"KD "
);
carta4
=
new
Carta
(
"AD "
);
carta5
=
new
Carta
(
"AC"
);
carta1
=
new
Carta
(
"KS "
);
carta2
=
new
Carta
(
"6C "
);
carta3
=
new
Carta
(
"6H "
);
carta4
=
new
Carta
(
"6D "
);
carta5
=
new
Carta
(
"KC "
);
mano
.
add
(
carta1
);
mano
.
add
(
carta2
);
mano
.
add
(
carta3
);
mano
.
add
(
carta4
);
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
());
System
.
out
.
println
(
""
);
System
.
out
.
print
(
"MANO: "
);
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
());
System
.
out
.
print
(
mano
.
get
(
i
).
valorPalo
()
+
" "
);
System
.
out
.
println
(
" "
);
resultado
=
poker
.
jugadas
(
mano
);
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