Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
Java_009_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
William Gonzalez
Java_009_Poker
Commits
fb86f6e3
Commit
fb86f6e3
authored
Oct 27, 2021
by
willgonzz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
210 additions
and
0 deletions
+210
-0
MainWilliam.java
+33
-0
PokerWilliam.java
+177
-0
probabilidades.docx
+0
-0
No files found.
MainWilliam.java
0 → 100644
View file @
fb86f6e3
public
class
MainWilliam
{
public
static
void
main
(
String
[]
args
)
{
Poker
p
=
new
Poker
();
String
c
[]={
"2S"
,
"3S"
,
"4S"
,
"5S"
,
"6S"
};
p
.
setCartas
(
c
);
p
.
recorrer
();
String
d
[]={
"2S"
,
"2C"
,
"2D"
,
"2H"
,
"6S"
};
p
.
setCartas
(
d
);
p
.
recorrer
();
String
full
[]={
"2S"
,
"3S"
,
"2C"
,
"3D"
,
"3H"
};
p
.
setCartas
(
full
);
p
.
recorrer
();
String
color
[]={
"2S"
,
"3S"
,
"4S"
,
"5S"
,
"8S"
};
p
.
setCartas
(
color
);
p
.
recorrer
();
String
escalera
[]={
"3H"
,
"4D"
,
"5C"
,
"6S"
,
"7S"
};
p
.
setCartas
(
escalera
);
p
.
recorrer
();
String
trio
[]={
"3S"
,
"2C"
,
"3D"
,
"3H"
,
"4S"
};
p
.
setCartas
(
trio
);
p
.
recorrer
();
String
doblePar
[]={
"3D"
,
"3H"
,
"4S"
,
"4D"
,
"7H"
};
p
.
setCartas
(
doblePar
);
p
.
recorrer
();
String
doble
[]={
"3D"
,
"3H"
,
"4S"
,
"2D"
,
"5S"
};
p
.
setCartas
(
doble
);
p
.
recorrer
();
String
cartaAlta
[]={
"4S"
,
"9D"
,
"2S"
,
"3H"
,
"5C"
};
p
.
setCartas
(
cartaAlta
);
p
.
recorrer
();
}
}
\ No newline at end of file
PokerWilliam.java
0 → 100644
View file @
fb86f6e3
public
class
PokerWilliam
{
private
String
cartas
[];
public
Poker
()
{
this
.
cartas
=
new
String
[
5
];
}
public
String
[]
getCartas
()
{
return
this
.
cartas
;
}
public
void
setCartas
(
String
[]
cartas
)
{
this
.
cartas
=
cartas
;
}
public
static
int
convertir
(
char
a
){
if
(
a
!=
'A'
||
a
!=
'T'
||
a
!=
'J'
||
a
!=
'Q'
||
a
!=
'K'
){
return
Character
.
getNumericValue
(
a
);
}
else
if
(
a
==
'A'
){
return
1
;
}
else
if
(
a
==
'T'
){
return
10
;
}
else
if
(
a
==
'J'
){
return
11
;
}
else
if
(
a
==
'Q'
){
return
12
;
}
else
if
(
a
==
'K'
){
return
13
;
}
else
{
return
0
;
}
}
public
static
void
ordenarInt
(
int
a
[]){
int
aux
;
for
(
int
i
=
0
;
i
<
4
;
i
++){
for
(
int
j
=
i
+
1
;
j
<
5
;
j
++){
if
(
a
[
i
]>
a
[
j
]){
aux
=
a
[
i
];
a
[
i
]=
a
[
j
];
a
[
j
]=
aux
;
}
}
}
}
public
static
int
iguales
(
int
a
[]){
ordenarInt
(
a
);
int
c
=
1
;
int
auxdoble
=
0
;
int
auxtriple
=
0
;
for
(
int
i
=
0
;
i
<
4
;
i
++){
if
(
a
[
i
]==
a
[
i
+
1
]){
c
++;
if
(
c
==
2
){
auxdoble
++;
}
else
if
(
c
==
3
){
auxdoble
--;
auxtriple
++;
}
else
if
(
c
==
4
){
return
4
;
}
}
else
if
(
i
!=
4
){
c
=
1
;
}
}
if
(
auxtriple
==
1
&&
auxdoble
==
1
){
return
3
;
}
else
if
(
auxtriple
==
1
){
return
2
;
}
else
if
(
auxdoble
==
2
){
return
1
;
}
else
if
(
auxdoble
==
1
){
return
0
;
}
else
{
return
-
1
;
}
}
public
static
void
ordenarString
(
char
a
[]){
char
aux
;
for
(
int
i
=
0
;
i
<
4
;
i
++){
for
(
int
j
=
i
+
1
;
j
<
5
;
j
++){
if
(
a
[
i
]>
a
[
j
]){
aux
=
a
[
i
];
a
[
i
]=
a
[
j
];
a
[
j
]=
aux
;
}
}
}
}
public
static
int
verificaPalo
(
char
palo
[]){
ordenarString
(
palo
);
int
c
=
1
;
for
(
int
i
=
0
;
i
<
4
;
i
++){
if
(
palo
[
i
]==
palo
[
i
+
1
]){
c
++;
}
}
if
(
c
==
5
){
return
2
;
}
else
if
(
c
==
4
){
return
1
;
}
else
{
return
0
;
}
}
public
static
int
verificasucesion
(
int
a
[]){
ordenarInt
(
a
);
int
c
=
1
;
if
(
a
[
0
]==
1
){
for
(
int
i
=
0
;
i
<
4
;
i
++){
if
(
a
[
i
]==(
a
[
i
+
1
]+
1
)){
c
++;
}
else
{
break
;
}
}
if
(
c
==
5
){
return
c
;
}
c
=
1
;
for
(
int
i
=
1
;
i
<
5
;
i
++){
a
[
i
-
1
]=
a
[
i
];
}
a
[
4
]=
14
;
for
(
int
i
=
0
;
i
<
4
;
i
++){
if
(
a
[
i
]==(
a
[
i
+
1
]+
1
)){
c
++;
}
else
{
break
;
}
}
}
else
{
for
(
int
i
=
0
;
i
<
4
;
i
++){
if
(
a
[
i
]+
1
==(
a
[
i
+
1
])){
c
++;
}
else
{
break
;
}
}
}
return
c
;
}
public
void
recorrer
(){
int
j
=
0
;
char
tipo
[]=
new
char
[
5
];
int
i
[]=
new
int
[
5
];
for
(
String
carta:
this
.
cartas
){
i
[
j
]=
convertir
(
carta
.
charAt
(
0
));
tipo
[
j
]=
carta
.
charAt
(
1
);
System
.
out
.
print
(
carta
+
"|"
);
j
++;
}
if
(
verificaPalo
(
tipo
)==
2
&&
verificasucesion
(
i
)==
5
){
System
.
out
.
println
(
"\nUsted tiene una Escalera Color"
);
}
else
if
(
iguales
(
i
)==
4
){
System
.
out
.
println
(
"\nUsted tiene una Poker"
);
}
else
if
(
iguales
(
i
)==
3
){
System
.
out
.
println
(
"\nUsted tiene Full"
);
}
else
if
(
verificaPalo
(
tipo
)==
2
){
System
.
out
.
println
(
"\nUsted tiene color"
);
}
else
if
(
verificasucesion
(
i
)==
5
){
System
.
out
.
println
(
"\nUsted tiene escalera"
);
}
else
if
(
iguales
(
i
)==
2
){
System
.
out
.
println
(
"\nUsted tiene trio"
);
}
else
if
(
iguales
(
i
)==
1
){
System
.
out
.
println
(
"\nUsted tiene par doble"
);
}
else
if
(
iguales
(
i
)==
0
){
System
.
out
.
println
(
"\nUsted tiene par"
);
}
else
{
System
.
out
.
println
(
"\nUsted tiene carta Alta"
);
}
}
}
\ No newline at end of file
probabilidades.docx
0 → 100644
View file @
fb86f6e3
File added
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