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
Yovan Martinez
poker
Commits
3f00972b
Commit
3f00972b
authored
Apr 26, 2022
by
Yovan Martinez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version que es objeto y no es objeto
parent
f4dcd34d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
68 deletions
+79
-68
Carta.java
+79
-68
No files found.
Carta.java
View file @
3f00972b
import
javax.lang.model.element.Element
;
import
javax.print.DocFlavor.STRING
;
import
java.util.Arrays
;
public
class
Carta
{
public
String
valor
;
public
String
palo
;
public
Carta
()
{
palo
=
""
;
public
String
suit
=
""
;
public
String
values
=
""
;
public
Carta
(){
valor
=
""
;
}
palo
=
""
;
}
//Constructor que puso el profe con intenciones que desconozco
public
Carta
(
String
completo
)
{
this
.
valor
=
String
.
valueOf
(
completo
.
charAt
(
0
));
this
.
palo
=
String
.
valueOf
(
completo
.
charAt
(
1
));
this
.
valor
=
valor
+
ordenarCadena
(
String
.
valueOf
(
completo
.
charAt
(
0
)
));
this
.
palo
=
palo
+
ordenarCadena
(
String
.
valueOf
(
completo
.
charAt
(
1
)
));
}
//Guarda todos los valores de palo de las cartas en un solo string para guardarlos
public
void
armarPalos
(
String
carta
){
palo
=
palo
+
ordenarCadena
(
String
.
valueOf
(
carta
.
charAt
(
1
)));
suit
=
ordenarCadena
(
suit
+
ordenarCadena
(
String
.
valueOf
(
carta
.
charAt
(
1
)
)));
}
//Guarda todos los valores de las cartas en un solo string para trabajarlos
public
void
armarValores
(
String
valores
){
valor
=
valor
+
ordenarCadena
(
String
.
valueOf
(
valores
.
charAt
(
0
)));
values
=
ordenarCadena
(
values
+
String
.
valueOf
(
valores
.
charAt
(
0
)));
}
public
String
get
Palo
(){
return
palo
;
public
String
get
Suit
(){
return
suit
;
}
public
String
getVal
or
(){
return
val
or
;
public
String
getVal
ue
(){
return
val
ues
;
}
//Segunda cosa que puso el profe con intenciones desconocidas para la mente promedio
String
valorPalo
()
{
return
this
.
valor
+
this
.
palo
;
}
//Controla que jugadas se da en los palos
private
int
controlPalos
(
String
palos
){
//*************CONTROLA QUE JUGADA SE DA EN LOS PALOS
public
int
controlPalos
(
String
palos
){
int
contador
=
0
;
for
(
int
i
=
0
;
i
<
palos
.
length
();
i
++)
{
for
(
int
j
=
0
;
j
<
palos
.
length
();
j
++)
{
...
...
@@ -47,13 +49,11 @@ public class Carta {
}
return
contador
;
}
//Controla que jugadas se da en los palos
private
int
controlValor
(
String
valores
){
//***********CONTROLA QUE JUGADA SE DA EN LOS VALORES
public
String
controlValor
(
String
valores
){
int
contador
=
0
;
int
secuencial
=
0
;
boolean
thereIsLetter
=
false
;
for
(
int
i
=
0
;
i
<
valores
.
length
();
i
++)
{
for
(
int
j
=
0
;
j
<
valores
.
length
();
j
++)
{
if
(
valores
.
charAt
(
i
)
==
valores
.
charAt
(
j
))
{
...
...
@@ -61,38 +61,68 @@ public class Carta {
}
}
}
// if (contador < 6) {
// switch (key) {
// case value:
// break;
// default:
// break;
// }
// } else {
// }
return
0
;
if
(
contador
<
6
)
{
//controla que existan letras en los valores mandados
for
(
int
i
=
0
;
i
<
valores
.
length
();
i
++)
{
String
l
=
String
.
valueOf
(
valores
.
charAt
(
i
));
if
(
l
==
"T"
||
l
==
"J"
||
l
==
"Q"
||
l
==
"K"
||
l
==
"A"
)
{
thereIsLetter
=
true
;
break
;
}
}
//Una condicional para el caso que existan letras
if
(
thereIsLetter
==
false
){
//Para mejor entendimiento visual lo guardo en una variable de nombre mas corto
String
v
=
getValue
();
if
(
(
v
.
equals
(
"89JQT"
))
||
(
v
.
equals
(
"9JKQT"
))
||
((
v
).
equals
(
"AJKQT"
))
||(
v
.
equals
(
"2345A"
))
||
(
v
.
equals
(
"789JT"
))
||(
v
.
equals
(
"6789T"
))){
return
"ESCALERA"
;
}
}
else
{
for
(
int
i
=
1
;
i
<
valores
.
length
();
i
++)
{
if
(
valores
.
charAt
(
i
)
==
valores
.
charAt
(
i
-
1
)
+
1
)
{
secuencial
++;
}
}
if
(
secuencial
==
4
)
{
return
"ESCALERA"
;
}
}
}
else
if
(
contador
==
17
)
{
return
"POKER"
;
}
else
if
(
contador
==
13
){
return
"FULL"
;
}
else
if
(
contador
==
11
){
return
"TRIO"
;
}
else
if
(
contador
==
9
){
return
"PAR DOBLE"
;
}
else
if
(
contador
==
7
){
return
"PAR"
;
}
return
"NADA"
;
}
//Valora la mano y devuelve un resultado final (depende en su totalidad de otros metodos)
public
String
valoracionMano
(){
if
(
controlPalos
(
getPalo
())
==
17
&&
controlValor
(
getValor
())
==
0
){
if
(
controlPalos
(
getSuit
())
==
25
&&
controlValor
(
getValue
()).
equals
(
"ESCALERA"
)){
return
"ESCALERA COLOR"
;
}
else
if
(
controlPalos
(
getSuit
())
<
25
&&
controlValor
(
getValue
()).
equals
(
"POKER"
)){
return
"POKER"
;
}
else
if
(
controlPalos
(
getSuit
())
<
25
&&
controlValor
(
getValue
()).
equals
(
"FULL"
))
{
return
"FULL"
;
}
else
if
(
controlPalos
(
getSuit
())
==
25
&&
controlValor
(
getValue
()).
equals
(
"NADA"
)
)
{
return
"COLOR"
;
}
else
if
(
controlPalos
(
getSuit
())
<
25
&&
controlValor
(
getValue
()).
equals
(
"ESCALERA"
)
)
{
return
"ESCALERA"
;
}
else
if
(
controlPalos
(
getSuit
())
<
25
&&
controlValor
(
getValue
()).
equals
(
"TRIO"
)
)
{
return
"TRIO"
;
}
else
if
(
controlPalos
(
getSuit
())
<
25
&&
controlValor
(
getValue
()).
equals
(
"PAR"
)
)
{
return
"PAR"
;
}
else
if
(
controlPalos
(
getSuit
())
<
25
&&
controlValor
(
getValue
()).
equals
(
"PAR DOBLE"
)
)
{
return
"PAR DOBLE"
;
}
return
"NADA"
;
}
//Recibe un string y lo ordena segun orden numerico o alfabetico
public
String
ordenarCadena
(
String
original
){
String
numeroAOrdenar
=
original
;
numeroAOrdenar
=
original
;
char
[]
chars
=
numeroAOrdenar
.
toCharArray
();
...
...
@@ -101,33 +131,14 @@ public class Carta {
return
cadenaOrdenada
;
}
public
static
void
main
(
String
[]
args
)
{
Carta
partida
=
new
Carta
();
String
[]
Mano
=
new
String
[]{
"5H"
,
"4C"
,
"AS"
,
"AS"
,
"2D"
,};
String
manoCompleta
=
""
;
boolean
check
=
false
;
int
contador
=
0
;
for
(
int
i
=
0
;
i
<
Mano
.
length
;
i
++)
{
for
(
int
j
=
0
;
j
<
Mano
.
length
;
j
++)
{
if
(
Mano
[
i
].
equals
(
Mano
[
j
]))
{
contador
++;
}
}
}
if
(
contador
<
6
){
for
(
int
i
=
0
;
i
<
Mano
.
length
;
i
++){
partida
.
armarPalos
(
Mano
[
i
]);
partida
.
armarValores
(
Mano
[
i
]);
}
System
.
out
.
println
(
"Aca tenes desordenado che kp: "
+
partida
.
palo
);
System
.
out
.
println
(
"Aca tenes desordenado che kp: "
+
partida
.
valor
);
System
.
out
.
println
(
"Aca tenes ordenado che kp: "
+
partida
.
ordenarCadena
(
partida
.
getPalo
()));
System
.
out
.
println
(
"Aca tenes ordenado che kp: "
+
partida
.
ordenarCadena
(
partida
.
getValor
()));
}
else
{
System
.
out
.
println
(
"Mano invalida por favor intente de nuevo"
);
Carta
cartas
=
new
Carta
();
String
[]
mano
=
new
String
[]{
"TH"
,
"JH"
,
"QH"
,
"KH"
,
"AH"
};
for
(
int
i
=
0
;
i
<
mano
.
length
;
i
++)
{
cartas
.
armarPalos
(
mano
[
i
]);
cartas
.
armarValores
(
mano
[
i
]);
}
System
.
out
.
println
(
cartas
.
valoracionMano
());
}
}
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