Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java-e005-poker-02
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
java-e005-poker-02
Commits
ef3bac41
Commit
ef3bac41
authored
May 02, 2022
by
Josebaezx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Se mejoran metodos para verificar jugada
parent
0589aa52
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
39 deletions
+21
-39
out/production/java-e005-poker-02/Carta.class
+0
-0
out/production/java-e005-poker-02/Juego.class
+0
-0
out/production/java-e005-poker-02/MyClass.class
+0
-0
src/Carta.java
+6
-7
src/Juego.java
+13
-29
src/MyClass.java
+2
-3
No files found.
out/production/java-e005-poker-02/Carta.class
View file @
ef3bac41
No preview for this file type
out/production/java-e005-poker-02/Juego.class
View file @
ef3bac41
No preview for this file type
out/production/java-e005-poker-02/MyClass.class
View file @
ef3bac41
No preview for this file type
src/Carta.java
View file @
ef3bac41
...
...
@@ -5,6 +5,8 @@ import java.util.Objects;
public
class
Carta
{
private
String
valor
;
private
String
palo
;
private
final
int
MIN
=
1
;
private
final
int
MAX
=
4
;
public
Carta
()
{
valorAleatorio
();
...
...
@@ -40,9 +42,8 @@ public class Carta {
public
void
valorAleatorio
(){
int
max
=
13
;
int
min
=
1
;
int
range
=
max
-
min
+
1
;
int
rand
=
(
int
)(
Math
.
random
()
*
range
)
+
min
;
int
range
=
max
-
MIN
+
1
;
int
rand
=
(
int
)(
Math
.
random
()
*
range
)
+
MIN
;
for
(
int
i
=
0
;
i
<
1
;
i
++)
{
if
(
rand
==
10
){
this
.
valor
=
"T"
;
...
...
@@ -65,10 +66,8 @@ public class Carta {
}
public
void
paloAleatorio
(){
int
max
=
4
;
int
min
=
1
;
int
range
=
max
-
min
+
1
;
int
rand
=
(
int
)(
Math
.
random
()
*
range
)
+
min
;
int
range
=
MAX
-
MIN
+
1
;
int
rand
=
(
int
)(
Math
.
random
()
*
range
)
+
MIN
;
for
(
int
i
=
0
;
i
<
1
;
i
++)
{
if
(
rand
==
1
){
this
.
palo
=
"C"
;
...
...
src/Juego.java
View file @
ef3bac41
...
...
@@ -39,44 +39,35 @@ public class Juego {
}
public
int
juegosPosibles
(
List
<
Carta
>
cartas
)
{
boolean
siguiente
=
true
;
if
(
escaleraColor
(
cartas
))
{
siguiente
=
false
;
System
.
out
.
println
(
"ESCALERA COLOR"
);
return
9
;
}
if
(
siguiente
&&
poker
(
cartas
))
{
siguiente
=
false
;
if
(
poker
(
cartas
))
{
System
.
out
.
println
(
"ESCALERA COLOR"
);
return
8
;
}
if
(
siguiente
&&
full
(
cartas
))
{
siguiente
=
false
;
if
(
full
(
cartas
))
{
System
.
out
.
println
(
"FULL"
);
return
7
;
}
if
(
siguiente
&&
escalera
(
cartas
))
{
siguiente
=
false
;
if
(
escalera
(
cartas
))
{
System
.
out
.
println
(
"ESCALERA"
);
return
6
;
}
if
(
siguiente
&&
color
(
cartas
))
{
siguiente
=
false
;
if
(
color
(
cartas
))
{
System
.
out
.
println
(
"COLOR"
);
return
5
;
}
if
(
siguiente
&&
trio
(
cartas
))
{
siguiente
=
false
;
if
(
trio
(
cartas
))
{
System
.
out
.
println
(
"TRIO"
);
return
4
;
}
if
(
siguiente
&&
parDoble
(
cartas
))
{
siguiente
=
false
;
if
(
parDoble
(
cartas
))
{
System
.
out
.
println
(
"PAR DOBLE"
);
return
3
;
}
if
(
siguiente
&&
par
(
cartas
))
{
siguiente
=
false
;
if
(
par
(
cartas
))
{
System
.
out
.
println
(
"PAR"
);
return
1
;
}
...
...
@@ -263,7 +254,7 @@ public class Juego {
}
contador
+=
valoresArry
[
i
];
if
(
contador
==
34
&&
valoresArry
[
0
]
==
1
)
{
if
(
contador
==
21
&&
valoresArry
[
0
]
==
1
)
{
return
true
;
}
}
...
...
@@ -338,28 +329,21 @@ public class Juego {
}
public
boolean
isRepetidos
(
Carta
[]
m1
,
Carta
[]
m2
)
{
Carta
[]
m3
=
new
Carta
[
10
];
Set
<
Carta
>
cartas
=
new
HashSet
<>();
int
c
=
5
;
for
(
int
i
=
0
;
i
<
m3
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
if
(
i
<
5
)
{
m3
[
i
]
=
(
m1
[
i
]);
cartas
.
add
(
m1
[
i
]);
}
else
if
(
i
>
4
)
{
m3
[
i
]
=
(
m2
[
i
-
c
]);
cartas
.
add
(
m2
[
i
-
c
]);
}
}
List
<
Carta
>
cartas
=
new
ArrayList
(
Arrays
.
asList
(
m3
));
List
<
Carta
>
distinctElementList
=
cartas
.
stream
()
.
distinct
()
.
collect
(
Collectors
.
toList
());
if
(
distinctElementList
.
size
()
<
10
)
{
if
(
cartas
.
size
()
<
10
)
{
return
false
;
}
return
true
;
}
}
src/MyClass.java
View file @
ef3bac41
...
...
@@ -43,16 +43,15 @@ public class MyClass {
respuesta
=
j
.
isRepetidos
(
m1
,
m2
);
}
while
(
respuesta
==
false
);
jugadas
.
add
(
m1
);
jugadas
.
add
(
m2
);
String
ganadores
=
mc
.
ganadores
(
jugadas
);
System
.
out
.
println
(
"\n"
+
ganadores
);
System
.
out
.
print
(
"Jugada 1 = "
);
int
valor
=
j
.
juegosPosibles
(
Arrays
.
asList
(
m1
[
0
],
m1
[
1
]
,
m1
[
2
]
,
m1
[
3
]
,
m1
[
4
]
));
int
valor
=
j
.
juegosPosibles
(
Arrays
.
asList
(
m1
));
System
.
out
.
print
(
"Jugada 2 = "
);
int
valor2
=
j
.
juegosPosibles
(
Arrays
.
asList
(
m2
[
0
],
m2
[
1
]
,
m2
[
2
]
,
m2
[
3
]
,
m2
[
4
]
));
int
valor2
=
j
.
juegosPosibles
(
Arrays
.
asList
(
m2
));
System
.
out
.
println
(
"GANADOR JUGADA # "
+
j
.
mano1VsMano2
(
valor
,
valor2
));
//Si son iguales realiza un desempate
...
...
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