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
10f9d3f2
Commit
10f9d3f2
authored
2 years ago
by
Yovan Martinez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Creacion clase poker
parent
3f00972b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
0 deletions
+101
-0
Poker.java
+101
-0
No files found.
Poker.java
0 → 100644
View file @
10f9d3f2
public
class
Poker
{
public
String
valoracionMano
(){
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"
;
}
public
String
controlPalos
(
String
palos
){
int
contador
=
0
;
for
(
int
i
=
0
;
i
<
palos
.
length
();
i
++)
{
for
(
int
j
=
0
;
j
<
palos
.
length
();
j
++)
{
if
(
palos
.
charAt
(
i
)
==
palos
.
charAt
(
j
))
{
contador
++;
}
}
}
if
(
contador
==
25
)
{
return
"COLOR"
}
else
{
}
return
contador
;
}
//***********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
))
{
contador
++;
}
}
}
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"
;
}
public
static
void
main
(
String
[]
args
)
{
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
());
}
}
This diff is collapsed.
Click to expand it.
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