Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java-e005
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
Silvia Barrientos
java-e005
Commits
4f285d4a
Commit
4f285d4a
authored
Sep 15, 2020
by
Silvia Barrientos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add GENERALA
parents
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
0 deletions
+100
-0
Generala.java
+95
-0
README.md
+5
-0
No files found.
Generala.java
0 → 100644
View file @
4f285d4a
import
java.util.*
;
public
class
Generala
{
static
final
int
JUGADAS
=
5
;
String
jugada
(
String
dados
){
char
aux
[]
=
dados
.
toCharArray
();
Arrays
.
sort
(
aux
);
int
acu
=
1
;
int
jug1
=
0
;
int
jug2
=
0
;
char
aux1
=
aux
[
0
];
if
(
aux1
>
'6'
||
aux1
<
'1'
){
return
"INVALIDO"
;
}
while
(
aux
.
length
==
JUGADAS
){
for
(
int
i
=
1
;
i
<
JUGADAS
;
i
++){
if
(
aux
[
i
]
>
'6'
||
aux
[
i
]
<
'1'
){
return
"INVALIDO"
;
}
if
(
aux1
==
aux
[
i
]){
acu
++;
}
}
if
(
acu
==
JUGADAS
){
return
"GENERALA"
;
}
acu
=
1
;
for
(
int
i
=
1
;
i
<
JUGADAS
;
i
++){
if
(
aux1
==
aux
[
i
]){
acu
++;
}
else
{
aux1
=
aux
[
i
];
jug1
=
acu
;
acu
=
1
;
}
}
jug2
=
acu
;
if
(
jug1
==
4
&&
jug2
==
1
){
return
"PÓKER"
;
}
else
if
(
jug1
==
1
&&
jug2
==
4
){
return
"PÓKER"
;
}
if
(
jug1
==
3
&&
jug2
==
2
){
return
"FULL"
;
}
else
if
(
jug1
==
2
&&
jug2
==
3
){
return
"FULL"
;
}
int
num1
=
Integer
.
parseInt
(
String
.
valueOf
(
aux
[
0
]));
int
num2
=
0
;
boolean
bandera
=
false
;
for
(
int
i
=
1
;
i
<
JUGADAS
;
i
++){
num2
=
Integer
.
parseInt
(
String
.
valueOf
(
aux
[
i
]));
if
(
num1
+
i
==
num2
){
bandera
=
true
;
}
else
{
bandera
=
false
;
}
}
if
(
bandera
==
true
){
return
"ESCALERA"
;
}
return
"NADA"
;
}
return
"INVALIDO"
;
}
String
[]
jugadas
(
String
[]
losdados
){
String
[]
ret
=
new
String
[
losdados
.
length
];
int
i
=
0
;
for
(
String
dados
:
losdados
){
ret
[
i
]
=
this
.
jugada
(
dados
);
i
++;
}
return
ret
;
}
public
static
void
main
(
String
[]
args
)
{
Generala
genera
=
new
Generala
();
Scanner
entradaJugadas
=
new
Scanner
(
System
.
in
);
System
.
out
.
print
(
"Ingrese jugada: "
);
String
jugadas
=
entradaJugadas
.
nextLine
();
entradaJugadas
.
close
();
String
array
[];
array
=
new
String
[
1
];
array
[
0
]
=
jugadas
;
System
.
out
.
print
(
genera
.
jugada
(
array
[
0
]));
}
}
\ No newline at end of file
README.md
0 → 100644
View file @
4f285d4a
Para compilar los ejercicos
-
Abrir el archivo en el editor de texto de preferencia.
-
Compilar el archivo (F5 en VisualStudio Code).
-
Se mostrar o requerira datos por consola.
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