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
Emanuel Lugo
poker
Commits
7116abc8
Commit
7116abc8
authored
Apr 26, 2022
by
Emanuel Lugo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Funciones para ordenar la lista de Cartas agregada
parent
08cbdd65
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
16 deletions
+65
-16
Carta.java
+6
-0
SortbyPalo.java
+12
-0
SortbyValor.java
+12
-0
pokerGame.java
+35
-16
No files found.
Carta.java
View file @
7116abc8
...
...
@@ -19,6 +19,12 @@ public class Carta {
{
return
this
.
valor
+
this
.
palo
;
}
}
...
...
SortbyPalo.java
0 → 100644
View file @
7116abc8
import
java.util.Comparator
;
class
SortbyPalo
implements
Comparator
<
Carta
>
{
// Used for sorting in ascending order of
// Ordenar por Palo
public
int
compare
(
Carta
a
,
Carta
b
)
{
return
a
.
palo
.
compareTo
(
b
.
palo
)
;
}
}
\ No newline at end of file
SortbyValor.java
0 → 100644
View file @
7116abc8
import
java.util.Comparator
;
class
SortbyValor
implements
Comparator
<
Carta
>
{
// Used for sorting in ascending order of
// Ordenar por Palo
public
int
compare
(
Carta
a
,
Carta
b
)
{
return
a
.
valor
.
compareTo
(
b
.
valor
)
;
}
}
\ No newline at end of file
pokerGame.java
View file @
7116abc8
/** */
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Scanner
;
import
java.util.*
;
public
class
pokerGame
{
...
...
@@ -18,28 +23,42 @@ public class pokerGame {
return
null
;
}
public
static
void
main
(
String
[]
args
)
{
pokerGame
poker
=
new
pokerGame
();
int
i
;
Carta
mano
[]
=
new
Carta
[
5
];
mano
[
0
]
=
new
Carta
(
"AS"
);
mano
[
1
]
=
new
Carta
(
"2S"
);
mano
[
2
]=
new
Carta
(
"3S"
);
mano
[
3
]=
new
Carta
(
"4S"
);
mano
[
4
]=
new
Carta
(
"5S"
);
Carta
carta1
,
carta2
,
carta3
,
carta4
,
carta5
;
ArrayList
<
Carta
>
mano
=
new
ArrayList
<
Carta
>();
carta1
=
new
Carta
(
"AS"
);
carta2
=
new
Carta
(
"2S"
);
carta3
=
new
Carta
(
"3S"
);
carta4
=
new
Carta
(
"4S"
);
carta5
=
new
Carta
(
"5S"
);
mano
.
add
(
carta5
)
;
mano
.
add
(
carta4
)
;
mano
.
add
(
carta3
)
;
mano
.
add
(
carta2
)
;
mano
.
add
(
carta1
)
;
//System.out.println(mano);
for
(
i
=
0
;
i
<
mano
.
size
();
i
++)
System
.
out
.
println
(
mano
.
get
(
i
).
valorPalo
()
);
Collections
.
sort
(
mano
,
new
SortbyPalo
());
System
.
out
.
println
(
""
)
;
for
(
i
=
0
;
i
<
mano
.
size
();
i
++)
System
.
out
.
println
(
mano
.
get
(
i
).
valorPalo
());
for
(
i
=
0
;
i
<
5
;
i
++)
System
.
out
.
println
(
mano
[
i
].
valorPalo
());
poker
.
jugadas
(
mano
)
;
Collections
.
sort
(
mano
,
new
SortbyValor
());
System
.
out
.
println
(
""
)
;
for
(
i
=
0
;
i
<
mano
.
size
();
i
++)
System
.
out
.
println
(
mano
.
get
(
i
).
valorPalo
());
...
...
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