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
8183c0aa
Commit
8183c0aa
authored
2 years ago
by
Jose Baez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correccion metodo full
parent
fe215e30
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
36 deletions
+67
-36
Juego.java
+66
-35
Main.java
+1
-1
out/production/poker/Juego.class
+0
-0
out/production/poker/Main.class
+0
-0
No files found.
Juego.java
View file @
8183c0aa
...
...
@@ -71,54 +71,85 @@ public class Juego {
//Dos cartas iguales (mismo valor) junto con tres cartas iguales (mismo valor).
public
boolean
full
(
List
<
Carta
>
cartas
)
{
List
<
Integer
>
valores
=
new
ArrayList
<>();
for
(
Carta
c
:
cartas
)
{
valores
.
add
(
extraer
(
c
.
valor
));
}
Collections
.
sort
(
valores
);
int
[]
numerosArray
=
pasarAArray
(
valores
);
int
con
=
0
;
for
(
int
i
=
0
;
i
<
numerosArray
.
length
-
1
;
i
++)
{
if
(
numerosArray
[
i
]
==
numerosArray
[
i
+
1
])
{
con
++;
if
(
con
==
3
&&
numerosArray
[
2
]
==
numerosArray
[
4
]){
return
true
;
}
else
if
(
con
==
3
&&
numerosArray
[
2
]
==
numerosArray
[
0
]){
return
true
;
if
(
comprobarPoker
(
cartas
)==
3
){
List
<
Integer
>
valores
=
new
ArrayList
<>();
for
(
Carta
c
:
cartas
)
{
valores
.
add
(
extraer
(
c
.
valor
));
}
Collections
.
sort
(
valores
);
int
[]
numerosArray
=
pasarAArray
(
valores
);
int
con
=
0
;
for
(
int
i
=
0
;
i
<
numerosArray
.
length
-
1
;
i
++)
{
if
(
numerosArray
[
i
]
==
numerosArray
[
i
+
1
])
{
con
++;
if
(
con
==
3
&&
numerosArray
[
2
]
==
numerosArray
[
4
]){
return
true
;
}
else
if
(
con
==
3
&&
numerosArray
[
2
]
==
numerosArray
[
0
]){
return
true
;
}
}
}
return
false
;
}
else
{
return
false
;
}
return
false
;
}
//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
(
comprobarPoker
(
cartas
)==
4
){
List
<
Integer
>
valores
=
new
ArrayList
<>();
comprobarPoker
(
cartas
);
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
(
counter
>
cantidadNumero
){
numero
=
i
;
cantidadNumero
=
counter
;
if
(
cantidadNumero
==
4
){
return
true
;
}
else
{
return
false
;
}
counter
=
0
;
}
if
(
cantidadNumero
==
4
){
return
true
;
}
else
{
return
false
;
}
}
private
int
comprobarPoker
(
List
<
Carta
>
cartas
)
{
int
contador
=
0
;
for
(
Carta
c:
cartas
)
{
if
(
c
.
palo
.
equals
(
"K"
))
{
contador
++;
}
if
(
c
.
palo
.
equals
(
"Q"
))
{
contador
++;
}
if
(
c
.
palo
.
equals
(
"K"
))
{
contador
++;
}
if
(
c
.
palo
.
equals
(
"C"
))
{
contador
++;
}
}
return
contador
;
}
...
...
This diff is collapsed.
Click to expand it.
Main.java
View file @
8183c0aa
...
...
@@ -12,7 +12,7 @@ public class Main {
new
Carta
(
"QH"
),
new
Carta
(
"QH"
),
new
Carta
(
"QH"
),
new
Carta
(
"
5
S"
),
new
Carta
(
"
T
S"
),
new
Carta
(
"9C"
)
);
...
...
This diff is collapsed.
Click to expand it.
out/production/poker/Juego.class
View file @
8183c0aa
No preview for this file type
This diff is collapsed.
Click to expand it.
out/production/poker/Main.class
View file @
8183c0aa
No preview for this file type
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