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
0589aa52
Commit
0589aa52
authored
May 01, 2022
by
Josebaezx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mejora en la creacion de numeros aleatorios
parent
57e00f26
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
75 deletions
+27
-75
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
+1
-4
src/Juego.java
+20
-65
src/MyClass.java
+6
-6
No files found.
out/production/java-e005-poker-02/Carta.class
View file @
0589aa52
No preview for this file type
out/production/java-e005-poker-02/Juego.class
View file @
0589aa52
No preview for this file type
out/production/java-e005-poker-02/MyClass.class
View file @
0589aa52
No preview for this file type
src/Carta.java
View file @
0589aa52
...
@@ -39,7 +39,7 @@ public class Carta {
...
@@ -39,7 +39,7 @@ public class Carta {
}
}
public
void
valorAleatorio
(){
public
void
valorAleatorio
(){
int
max
=
1
4
;
int
max
=
1
3
;
int
min
=
1
;
int
min
=
1
;
int
range
=
max
-
min
+
1
;
int
range
=
max
-
min
+
1
;
int
rand
=
(
int
)(
Math
.
random
()
*
range
)
+
min
;
int
rand
=
(
int
)(
Math
.
random
()
*
range
)
+
min
;
...
@@ -56,9 +56,6 @@ public class Carta {
...
@@ -56,9 +56,6 @@ public class Carta {
else
if
(
rand
==
13
){
else
if
(
rand
==
13
){
this
.
valor
=
"K"
;
this
.
valor
=
"K"
;
}
}
else
if
(
rand
==
14
){
this
.
valor
=
"A"
;
}
else
if
(
rand
==
1
)
{
else
if
(
rand
==
1
)
{
this
.
valor
=
"A"
;
this
.
valor
=
"A"
;
}
else
{
}
else
{
...
...
src/Juego.java
View file @
0589aa52
import
org.w3c.dom.ls.LSOutput
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
public
class
Juego
{
public
class
Juego
{
List
<
Integer
>
valores
=
null
;
List
<
Integer
>
valores
=
null
;
final
int
MAX
=
3
;
final
int
MAX
=
3
;
final
int
MIN
=
1
;
final
int
MIN
=
1
;
public
Juego
()
{
public
Juego
()
{
}
}
...
@@ -337,74 +337,29 @@ public class Juego {
...
@@ -337,74 +337,29 @@ public class Juego {
return
value
;
return
value
;
}
}
public
int
isRepetidos
(
Carta
[]
m1
,
Carta
[]
m2
)
{
public
boolean
isRepetidos
(
Carta
[]
m1
,
Carta
[]
m2
)
{
Carta
[]
m3
=
new
Carta
[
10
];
Carta
[]
m3
=
new
Carta
[
10
];
Set
<
Carta
>
cartas
=
new
HashSet
<>();
int
c
=
5
;
int
c
=
5
;
for
(
int
i
=
0
;
i
<
m3
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
m3
.
length
;
i
++)
{
if
(
i
<
5
)
{
if
(
i
<
5
)
{
cartas
.
add
(
m1
[
i
]);
m3
[
i
]
=
(
m1
[
i
]);
}
else
if
(
i
>
4
)
{
}
else
if
(
i
>
4
)
{
cartas
.
add
(
m2
[
i
-
c
]);
m3
[
i
]
=
(
m2
[
i
-
c
]);
}
}
}
return
cartas
.
size
();
}
public
Carta
[]
cambiarMano1
(
Carta
[]
m1
)
{
int
range
=
MAX
-
MIN
+
1
;
int
rand
=
(
int
)
(
Math
.
random
()
*
range
)
+
MIN
;
if
(
rand
==
1
)
{
return
m1
=
new
Carta
[]{
new
Carta
(
"AS"
),
new
Carta
(
"2S"
),
new
Carta
(
"4S"
),
new
Carta
(
"6S"
),
new
Carta
(
"8S"
)};
}
else
if
(
rand
==
2
)
{
return
m1
=
new
Carta
[]{
new
Carta
(
"KH"
),
new
Carta
(
"2H"
),
new
Carta
(
"5C"
),
new
Carta
(
"TS"
),
new
Carta
(
"JS"
)};
}
else
{
return
m1
=
new
Carta
[]{
new
Carta
(
"JC"
),
new
Carta
(
"2H"
),
new
Carta
(
"5S"
),
new
Carta
(
"TC"
),
new
Carta
(
"JS"
)};
}
}
public
Carta
[]
cambiarMano2
(
Carta
[]
m2
)
{
int
range
=
MAX
-
MIN
+
1
;
int
rand
=
(
int
)
(
Math
.
random
()
*
range
)
+
MIN
;
if
(
rand
==
1
)
{
return
m2
=
new
Carta
[]{
new
Carta
(
"AK"
),
new
Carta
(
"TC"
),
new
Carta
(
"5H"
),
new
Carta
(
"TH"
),
new
Carta
(
"JH"
)};
}
else
if
(
rand
==
2
){
return
m2
=
new
Carta
[]{
new
Carta
(
"AC"
),
new
Carta
(
"6C"
),
new
Carta
(
"7H"
),
new
Carta
(
"8H"
),
new
Carta
(
"9H"
)};
}
else
{
return
m2
=
new
Carta
[]{
new
Carta
(
"TH"
),
new
Carta
(
"9C"
),
new
Carta
(
"5D"
),
new
Carta
(
"TH"
),
new
Carta
(
"JH"
)};
}
}
List
<
Carta
>
cartas
=
new
ArrayList
(
Arrays
.
asList
(
m3
));
List
<
Carta
>
distinctElementList
=
cartas
.
stream
()
.
distinct
()
.
collect
(
Collectors
.
toList
());
if
(
distinctElementList
.
size
()
<
10
)
{
return
false
;
}
}
return
true
;
}
}
}
src/MyClass.java
View file @
0589aa52
...
@@ -26,23 +26,23 @@ public class MyClass {
...
@@ -26,23 +26,23 @@ public class MyClass {
MyClass
mc
=
new
MyClass
();
MyClass
mc
=
new
MyClass
();
List
<
Carta
[]>
jugadas
=
new
ArrayList
<
Carta
[]>();
List
<
Carta
[]>
jugadas
=
new
ArrayList
<
Carta
[]>();
Carta
[]
m1
=
new
Carta
[
5
];
Carta
[]
m1
=
new
Carta
[
5
];
Carta
[]
m2
=
new
Carta
[
5
];
boolean
respuesta
=
false
;
do
{
m1
[
0
]
=
new
Carta
();
m1
[
0
]
=
new
Carta
();
m1
[
1
]
=
new
Carta
();
m1
[
1
]
=
new
Carta
();
m1
[
2
]
=
new
Carta
();
m1
[
2
]
=
new
Carta
();
m1
[
3
]
=
new
Carta
();
m1
[
3
]
=
new
Carta
();
m1
[
4
]
=
new
Carta
();
m1
[
4
]
=
new
Carta
();
Carta
[]
m2
=
new
Carta
[
5
];
m2
[
0
]
=
new
Carta
();
m2
[
0
]
=
new
Carta
();
m2
[
1
]
=
new
Carta
();
m2
[
1
]
=
new
Carta
();
m2
[
2
]
=
new
Carta
();
m2
[
2
]
=
new
Carta
();
m2
[
3
]
=
new
Carta
();
m2
[
3
]
=
new
Carta
();
m2
[
4
]
=
new
Carta
();
m2
[
4
]
=
new
Carta
();
respuesta
=
j
.
isRepetidos
(
m1
,
m2
);
}
while
(
respuesta
==
false
);
//System.out.println(j.isRepetidos(m1,m2));
if
(
j
.
isRepetidos
(
m1
,
m2
)
<
10
){
m1
=
j
.
cambiarMano1
(
m1
);
m2
=
j
.
cambiarMano2
(
m2
);
}
jugadas
.
add
(
m1
);
jugadas
.
add
(
m1
);
jugadas
.
add
(
m2
);
jugadas
.
add
(
m2
);
...
...
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