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
985dd79b
Commit
985dd79b
authored
Apr 27, 2022
by
Yovan Martinez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Agregado generacion de cartas aleatoria
parent
180c5a5c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
15 deletions
+45
-15
Poker.java
+45
-15
No files found.
Poker.java
View file @
985dd79b
...
@@ -3,6 +3,7 @@ import javax.lang.model.element.Element;
...
@@ -3,6 +3,7 @@ import javax.lang.model.element.Element;
import
javax.print.DocFlavor.STRING
;
import
javax.print.DocFlavor.STRING
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Random
;
public
class
Poker
{
public
class
Poker
{
...
@@ -118,26 +119,55 @@ public class Poker {
...
@@ -118,26 +119,55 @@ public class Poker {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
Carta
carta1
=
new
Carta
(
"8S"
);
Carta
carta1
=
new
Carta
(
"AA"
);
Carta
carta2
=
new
Carta
(
"7D"
);
Carta
carta2
=
new
Carta
(
"AA"
);
Carta
carta3
=
new
Carta
(
"6H"
);
Carta
carta3
=
new
Carta
(
"AA"
);
Carta
carta4
=
new
Carta
(
"TC"
);
Carta
carta4
=
new
Carta
(
"AA"
);
Carta
carta5
=
new
Carta
(
"9D"
);
Carta
carta5
=
new
Carta
(
"AA"
);
Carta
carta6
=
new
Carta
(
"AA"
);
Carta
carta7
=
new
Carta
(
"AA"
);
Carta
carta8
=
new
Carta
(
"AA"
);
Carta
carta9
=
new
Carta
(
"AA"
);
Carta
carta10
=
new
Carta
(
"AA"
);
Poker
partida
=
new
Poker
();
Poker
partida
=
new
Poker
();
int
control
=
0
;
//Variable para controlar el ingreso de cartas repetidas
String
[]
valores
=
{
"A"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"T"
,
"J"
,
"Q"
,
"K"
,};
//Le paso los valores con el metodo del profe
String
[]
palos
=
{
"D"
,
"S"
,
"C"
,
"H"
,};
String
[]
mano
=
new
String
[]{
carta1
.
valorPalo
(),
carta2
.
valorPalo
(),
carta3
.
valorPalo
(),
carta4
.
valorPalo
(),
carta5
.
valorPalo
(),};
String
[]
cartas
=
new
String
[
10
];
for
(
int
i
=
0
;
i
<
mano
.
length
;
i
++)
{
int
control
=
100
;
//Variable para controlar el ingreso de cartas repetidas
partida
.
setValues
(
mano
[
i
]);
Carta
[]
mano
=
new
Carta
[]{
carta1
,
carta2
,
carta3
,
carta4
,
carta5
,};
Carta
[]
mano2
=
new
Carta
[]{
carta6
,
carta7
,
carta8
,
carta9
,
carta10
,};
}
for
(
int
i
=
0
;
i
<
mano
.
length
;
i
++)
{
for
(
int
j
=
0
;
j
<
mano
.
length
;
j
++)
{
while
(
control
>
10
)
{
if
(
mano
[
i
].
equals
(
mano
[
j
]))
{
for
(
int
i
=
0
;
i
<
mano
.
length
;
i
++)
{
control
++;
mano2
[
i
].
valor
=
mano2
[
i
].
valor
.
concat
(
valores
[(
int
)
Math
.
floor
(
Math
.
random
()*(
11
-
0
+
1
)+
0
)]);
mano
[
i
].
palo
=
mano
[
i
].
palo
.
concat
(
palos
[(
int
)
Math
.
floor
(
Math
.
random
()*(
2
-
0
+
1
)+
0
)]);
}
for
(
int
i
=
0
;
i
<
mano2
.
length
;
i
++)
{
mano2
[
i
].
valor
=
mano2
[
i
].
valor
.
concat
(
valores
[(
int
)
Math
.
floor
(
Math
.
random
()*(
11
-
0
+
1
)+
0
)]);
mano2
[
i
].
palo
=
mano2
[
i
].
palo
.
concat
(
palos
[(
int
)
Math
.
floor
(
Math
.
random
()*(
2
-
0
+
1
)+
0
)]);
}
for
(
int
i
=
0
;
i
<
mano
.
length
;
i
++)
{
for
(
int
j
=
0
;
j
<
mano
.
length
;
j
++)
{
if
(
mano
[
i
].
valorPalo
().
equals
(
mano
[
j
].
valorPalo
()))
{
control
++;
}
}
}
for
(
int
i
=
0
;
i
<
mano2
.
length
;
i
++)
{
for
(
int
j
=
0
;
j
<
mano2
.
length
;
j
++)
{
if
(
mano2
[
i
].
valorPalo
().
equals
(
mano2
[
j
].
valorPalo
()))
{
control
++;
}
}
}
}
}
}
}
control
=
0
;
//Le paso los valores con el metodo del profe
for
(
int
i
=
0
;
i
<
mano
.
length
;
i
++)
{
partida
.
setValues
(
mano
[
i
].
valorPalo
());
}
//Condicional para imprimir los resultados solo si no se encontraron cartas repetidas
//Condicional para imprimir los resultados solo si no se encontraron cartas repetidas
if
(
control
==
5
){
if
(
control
==
5
){
if
((
partida
.
controlValor
(
partida
.
getValue
())==
""
)
&&
(
partida
.
controlPalos
(
partida
.
getSuit
())
==
""
))
{
if
((
partida
.
controlValor
(
partida
.
getValue
())==
""
)
&&
(
partida
.
controlPalos
(
partida
.
getSuit
())
==
""
))
{
...
...
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