Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wu-e002
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
Jose Figueredo
wu-e002
Commits
1f050df5
Commit
1f050df5
authored
Sep 01, 2020
by
Jose Figueredo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Arreglando detalles
parent
ec5bbb7d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
13 deletions
+39
-13
VacasToros.java
+39
-13
No files found.
VacasToros.java
View file @
1f050df5
...
...
@@ -15,10 +15,9 @@ public class VacasToros {
public
VacasToros
(
String
n
){
this
.
numero
=
n
;
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
a
[
i
]
=
n
.
charAt
(
i
);
}
a
=
n
.
toCharArray
();
verificar
(
a
);
}
...
...
@@ -46,7 +45,15 @@ public class VacasToros {
}
public
boolean
Fin
()
{
if
(
toros
==
4
)
{
return
true
;
}
return
false
;
}
public
boolean
verificar
(
String
c
){
char
d
[]=
new
char
[
4
];
for
(
int
i
=
0
;
i
<
4
;
i
++)
...
...
@@ -68,17 +75,26 @@ public class VacasToros {
}
}
}
if
(
d
[
0
]==
'0'
)
bandera
=
1
;
if
(
bandera
==
1
)
{
System
.
out
.
println
(
"El numero debe tener todos digitos distintos"
);
return
false
;
}
return
true
;
}
public
void
comparar
(
String
n
){
if
(!
verificar
(
n
))
{
return
;
}
char
b
[]=
new
char
[
4
];
toros
=
0
;
vacas
=
0
;
for
(
int
i
=
0
;
i
<
4
;
i
++)
...
...
@@ -125,28 +141,38 @@ public class VacasToros {
public
static
void
main
(
String
[]
args
)
{
VacasToros
juego
=
new
VacasToros
(
"1521"
);
Scanner
teclado
=
new
Scanner
(
System
.
in
);
String
a
=
teclado
.
nextLine
();
String
b
=
teclado
.
nextLine
();
// String b= teclado.nextLine();
VacasToros
juego
=
new
VacasToros
(
a
);
int
intento
=
0
;
String
b
;
while
(
juego
.
verificar
(
a
)
&&
juego
.
verificar
(
b
))
if
(
juego
.
verificar
(
a
))
{
do
{
intento
++;
System
.
out
.
println
(
"Intento B nro:"
+
intento
);
b
=
teclado
.
nextLine
();
juego
.
comparar
(
b
);
// no pude terminar por tiempo
}
}
while
(!
juego
.
Fin
()
&&
intento
<=
12
);
if
(
intento
>
12
)
System
.
out
.
println
(
"Se acabaron los intentos,El ganador es A , el numero era: "
+
a
);
else
System
.
out
.
println
(
"El ganador es B con "
+
intento
+
" intentos"
);
}
...
...
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