Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java-e003-generala
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
Pedro Rolon
java-e003-generala
Commits
23ba7ce5
Commit
23ba7ce5
authored
Oct 24, 2018
by
Pedro Rolon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Se solucionó un bug en la comprobación de las escaleras
parent
9cdb9e95
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
8 deletions
+45
-8
Generala.java
+45
-8
No files found.
Generala.java
View file @
23ba7ce5
...
@@ -20,12 +20,7 @@ public class Generala
...
@@ -20,12 +20,7 @@ public class Generala
//comprobar que sean 5 valores
//comprobar que sean 5 valores
if
(
dados
.
length
()
!=
5
){
if
(
dados
.
length
()
!=
5
){
return
"INVALIDO"
;
return
"INVALIDO"
;
}
}
//Para comprobar los tres casos posibles de escalera
if
(
dados
.
equals
(
"12345"
)
||
dados
.
equals
(
"23456"
)
||
dados
.
equals
(
"34561"
)){
return
"ESCALERA"
;
}
//array para tener la cantidad de apariciones de un número
//array para tener la cantidad de apariciones de un número
int
[]
cantidad
=
{
0
,
0
,
0
,
0
,
0
,
0
};
int
[]
cantidad
=
{
0
,
0
,
0
,
0
,
0
,
0
};
...
@@ -40,6 +35,48 @@ public class Generala
...
@@ -40,6 +35,48 @@ public class Generala
cantidad
[
index
-
1
]++;
cantidad
[
index
-
1
]++;
}
}
boolean
bandera
=
true
;
System
.
out
.
print
(
cantidad
[
0
]+
"|"
+
cantidad
[
1
]+
"|"
+
cantidad
[
2
]+
"|"
+
cantidad
[
3
]+
"|"
+
cantidad
[
4
]+
"|"
+
cantidad
[
5
]);
System
.
out
.
println
();
//Comprueba la escalera 12345
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
if
(
cantidad
[
i
]!=
1
){
bandera
=
false
;
break
;
}
}
if
(
bandera
){
return
"ESCALERA"
;
}
bandera
=
true
;
//Comprueba la escalera 23456
for
(
int
i
=
1
;
i
<
6
;
i
++)
{
if
(
cantidad
[
i
]!=
1
){
bandera
=
false
;
break
;
}
}
if
(
bandera
){
return
"ESCALERA"
;
}
bandera
=
true
;
//Comprueba la escalera 34561
for
(
int
i
=
2
;
i
<
6
;
i
++)
{
if
(
cantidad
[
i
]!=
1
){
bandera
=
false
;
break
;
}
}
if
(
cantidad
[
0
]!=
1
){
bandera
=
false
;
}
if
(
bandera
){
return
"ESCALERA"
;
}
//calcula el máximo del vector cantidad
//calcula el máximo del vector cantidad
int
max
=
maximo
(
cantidad
);
int
max
=
maximo
(
cantidad
);
//System.out.println(max);
//System.out.println(max);
...
@@ -139,7 +176,8 @@ public class Generala
...
@@ -139,7 +176,8 @@ public class Generala
System.out.println(g.jugada("23A23")); //INVALIDO
System.out.println(g.jugada("23A23")); //INVALIDO
System.out.println(g.jugada("55155")); //POKER
System.out.println(g.jugada("55155")); //POKER
*/
*/
}
}
}
}
\ No newline at end of file
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