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
Jose Baez
poker
Commits
cb4a47c9
Commit
cb4a47c9
authored
Apr 26, 2022
by
Jose Baez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Se agrega metodo poker
parent
65dd487c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
11 deletions
+47
-11
Juego.java
+44
-8
Main.java
+3
-3
out/production/poker/Juego.class
+0
-0
out/production/poker/Main.class
+0
-0
No files found.
Juego.java
View file @
cb4a47c9
...
...
@@ -9,25 +9,60 @@ public class Juego {
public
Juego
()
{
}
public
void
juegosPosibles
(
List
<
Carta
>
cartas
){
public
void
juegosPosibles
(
List
<
Carta
>
cartas
)
{
boolean
siguiente
=
true
;
if
(
escaleraColor
(
cartas
))
{
siguiente
=
false
;
if
(
escaleraColor
(
cartas
))
{
siguiente
=
false
;
System
.
out
.
println
(
"ESCALERA COLOR"
);
}
if
(
siguiente
&&
escalera
(
cartas
)){
siguiente
=
false
;
if
(
siguiente
&&
poker
(
cartas
))
{
siguiente
=
false
;
System
.
out
.
println
(
"POKER"
);
}
if
(
siguiente
&&
escalera
(
cartas
))
{
siguiente
=
false
;
System
.
out
.
println
(
"ESCALERA"
);
}
if
(
siguiente
&&
color
(
cartas
))
{
siguiente
=
false
;
if
(
siguiente
&&
color
(
cartas
))
{
siguiente
=
false
;
System
.
out
.
println
(
"COLOR"
);
}
if
(
siguiente
)
{
if
(
siguiente
)
{
System
.
out
.
println
(
"NADA"
);
}
}
//Cuatro cartas iguales (mismo valor).
public
boolean
poker
(
List
<
Carta
>
cartas
)
{
List
<
Integer
>
valores
=
new
ArrayList
<>();
for
(
Carta
c
:
cartas
)
{
valores
.
add
(
extraer
(
c
.
valor
));
}
Collections
.
sort
(
valores
);
int
counter
=
0
;
int
numero
=
0
;
int
cantidadNumero
=
0
;
for
(
int
i
=
1
;
i
<
14
;
i
++){
for
(
int
j
=
0
;
j
<
valores
.
size
();
j
++)
{
int
s
=
valores
.
get
(
j
);
if
(
s
==
i
){
counter
++;
}
}
if
(
counter
>
cantidadNumero
){
numero
=
i
;
cantidadNumero
=
counter
;
}
counter
=
0
;
}
if
(
cantidadNumero
==
4
){
return
true
;
}
else
{
return
false
;
}
}
public
boolean
color
(
List
<
Carta
>
cartas
)
{
String
valuePalo
=
estraerPalo
(
cartas
);
for
(
int
i
=
0
;
i
<
cartas
.
size
();
i
++)
{
...
...
@@ -37,6 +72,7 @@ public class Juego {
}
return
true
;
}
public
boolean
escalera
(
List
<
Carta
>
cartas
)
{
int
contador
=
0
;
List
<
Integer
>
valores
=
new
ArrayList
<>();
...
...
Main.java
View file @
cb4a47c9
...
...
@@ -10,9 +10,9 @@ public class Main {
List
<
Carta
>
cartas
=
new
ArrayList
<>();
cartas
=
Arrays
.
asList
(
new
Carta
(
"2H"
),
new
Carta
(
"
3
H"
),
new
Carta
(
"
4
H"
),
new
Carta
(
"
5H
"
),
new
Carta
(
"
6
H"
),
new
Carta
(
"
6
H"
),
new
Carta
(
"
6S
"
),
new
Carta
(
"6H"
)
);
...
...
out/production/poker/Juego.class
View file @
cb4a47c9
No preview for this file type
out/production/poker/Main.class
View file @
cb4a47c9
No preview for this file type
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