Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
js-e004
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
js-e004
Commits
88a90ac5
Commit
88a90ac5
authored
Sep 10, 2020
by
Silvia Barrientos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add js-e004
parents
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
620 additions
and
0 deletions
+620
-0
css/styles.css
+62
-0
js/javaScript.js
+226
-0
js/javaScript2.js
+282
-0
tateti.html
+50
-0
No files found.
css/styles.css
0 → 100644
View file @
88a90ac5
header
{
height
:
100px
;
background-color
:
dodgerblue
;
margin
:
0
;
display
:
flex
;
justify-content
:
space-between
;
}
h1
{
margin-top
:
30px
;
margin-left
:
90px
;
color
:
white
;
}
table
{
display
:
grid
;
grid-template-columns
:
repeat
(
2
,
1
fr
);
justify-content
:
center
;
padding-top
:
50px
;
padding-left
:
100px
;
}
button
{
width
:
70px
;
height
:
70px
;
font-size
:
xx-large
;
color
:
dodgerblue
;
}
.com
{
margin-left
:
100px
;
width
:
200px
;
}
.estboton
{
width
:
150px
;
margin-right
:
20px
;
margin-top
:
50px
;
background-color
:
dodgerblue
;
color
:
white
;
border-radius
:
10px
;
font-size
:
x-large
;
}
.com
{
margin-left
:
120px
;
width
:
200px
;
}
.XO
{
margin-top
:
50px
;
background-color
:
white
;
color
:
dodgerblue
;
border-radius
:
10px
;
}
js/javaScript.js
0 → 100644
View file @
88a90ac5
function
init
(){
var
turno
=
1
;
var
filas
=
[
0
,
0
,
0
];
var
columnas
=
[
0
,
0
,
0
];
var
diagonales
=
[
0
,
0
,
0
];
jug1
.
onclick
=
function
(){
var
nombre
=
prompt
(
"Ingresa nombre"
);
while
(
nombre
==
""
){
nombre
=
prompt
(
"Debe ingresa nombre"
);
}
jug1
.
textContent
=
nombre
;
}
jug2
.
onclick
=
function
(){
var
nombre
=
prompt
(
"Ingresa nombre"
);
while
(
nombre
==
""
){
nombre
=
prompt
(
"Debe ingresa nombre"
);
}
jug2
.
textContent
=
nombre
;
}
xo1
.
onclick
=
function
(){
if
(
xo1
.
textContent
!==
'X'
&&
xo1
.
textContent
!==
'O'
){
textContent
=
'X'
;
}
if
(
xo1
.
textContent
==
'X'
){
xo1
.
textContent
=
'O'
;
}
else
{
xo1
.
textContent
=
'X'
;
}
}
xo2
.
onclick
=
function
(){
if
(
xo2
.
textContent
!==
'X'
&&
xo2
.
textContent
!==
'O'
){
xo2
.
textContent
=
'X'
;
}
if
(
xo2
.
textContent
==
'X'
){
xo2
.
textContent
=
'O'
;
}
else
{
xo2
.
textContent
=
'X'
;
}
}
comenzar
.
onclick
=
function
(){
var
val
=
true
;
while
(
jug1
.
textContent
==
""
){
alert
(
"Jugador 1 debe ingresar un nombre"
);
val
=
false
;
break
;
}
while
(
jug2
.
textContent
==
""
){
alert
(
"Jugador 2 debe ingresar un nombre"
);
val
=
false
;
break
;
}
while
(
xo1
.
textContent
!==
'X'
&&
xo1
.
textContent
!==
'O'
){
alert
(
"Jugador 1 debe escoger X o O"
);
val
=
false
;
break
;
}
while
(
xo2
.
textContent
!==
'X'
&&
xo2
.
textContent
!==
'O'
){
alert
(
"Jugador 2 debe escoger X o O"
);
val
=
false
;
break
;
}
while
(
xo1
.
textContent
==
xo2
.
textContent
){
alert
(
"Jugador 2 debe escoger distinta opcion a jugador 1"
);
val
=
false
;
break
;
}
if
(
val
==
true
){
inicio
();
}
}
function
inicio
(){
var
i
=
0
;
A1
.
onclick
=
function
(){
if
(
turno
==
1
){
A1
.
textContent
=
'X'
}
else
{
A1
.
textContent
=
'O'
}
analizar
();
cambiarTurno
();
i
++
;
}
A2
.
onclick
=
function
(){
if
(
turno
==
1
){
A2
.
textContent
=
'X'
}
else
{
A2
.
textContent
=
'O'
}
analizar
();
cambiarTurno
();
i
++
;
}
A3
.
onclick
=
function
(){
if
(
turno
==
1
){
A3
.
textContent
=
'X'
}
else
{
A3
.
textContent
=
'O'
}
analizar
();
cambiarTurno
();
i
++
;
}
B1
.
onclick
=
function
(){
if
(
turno
==
1
){
B1
.
textContent
=
'X'
}
else
{
B1
.
textContent
=
'O'
}
analizar
();
cambiarTurno
();
i
++
;
}
B2
.
onclick
=
function
(){
if
(
turno
==
1
){
B2
.
textContent
=
'X'
}
else
{
B2
.
textContent
=
'O'
}
analizar
();
cambiarTurno
();
i
++
;
}
B3
.
onclick
=
function
(){
if
(
turno
==
1
){
B3
.
textContent
=
'X'
}
else
{
B3
.
textContent
=
'O'
}
analizar
();
cambiarTurno
();
i
++
;
}
C1
.
onclick
=
function
(){
if
(
turno
==
1
){
C1
.
textContent
=
'X'
}
else
{
C1
.
textContent
=
'O'
}
analizar
();
cambiarTurno
();
i
++
;
}
C2
.
onclick
=
function
(){
if
(
turno
==
1
){
C2
.
textContent
=
'X'
}
else
{
C2
.
textContent
=
'O'
}
analizar
();
cambiarTurno
();
i
++
;
}
C3
.
onclick
=
function
(){
if
(
turno
==
1
){
C3
.
textContent
=
'X'
}
else
{
C3
.
textContent
=
'O'
}
analizar
();
cambiarTurno
();
i
++
;
}
function
cambiarTurno
(){
if
(
turno
==
1
){
turno
=
0
;
}
else
{
turno
=
1
;
}
}
alert
(
"EMPATE"
);
}
function
analizar
(){
if
((
A1
.
textContent
==
'X'
)
&&
(
A2
.
textContent
==
'X'
)
&&
(
A3
.
textContent
==
'X'
)){
alert
(
"EL GANADOR ES: X"
);
}
else
if
((
A1
.
textContent
==
'O'
)
&&
(
A2
.
textContent
==
'O'
)
&&
(
A3
.
textContent
==
'O'
)){
alert
(
"EL GANADOR ES: O"
);
}
if
((
B1
.
textContent
==
'X'
)
&&
(
B2
.
textContent
==
'X'
)
&&
(
B3
.
textContent
==
'X'
)){
alert
(
"EL GANADOR ES: X"
);
}
else
if
((
B1
.
textContent
==
'O'
)
&&
(
B2
.
textContent
==
'O'
)
&&
(
B3
.
textContent
==
'O'
)){
alert
(
"EL GANADOR ES: O"
);
}
if
((
C1
.
textContent
==
'X'
)
&&
(
C2
.
textContent
==
'X'
)
&&
(
C3
.
textContent
==
'X'
)){
alert
(
"EL GANADOR ES: X"
);
}
else
if
((
C1
.
textContent
==
'O'
)
&&
(
C2
.
textContent
==
'O'
)
&&
(
C3
.
textContent
==
'O'
)){
alert
(
"EL GANADOR ES: O"
);
}
if
((
A1
.
textContent
==
'X'
)
&&
(
B1
.
textContent
==
'X'
)
&&
(
C1
.
textContent
==
'X'
)){
alert
(
"EL GANADOR ES: X"
);
}
else
if
((
A1
.
textContent
==
'O'
)
&&
(
B1
.
textContent
==
'O'
)
&&
(
C1
.
textContent
==
'O'
)){
alert
(
"EL GANADOR ES: O"
);
}
if
((
A2
.
textContent
==
'X'
)
&&
(
B2
.
textContent
==
'X'
)
&&
(
C2
.
textContent
==
'X'
)){
alert
(
"EL GANADOR ES: X"
);
}
else
if
((
A2
.
textContent
==
'O'
)
&&
(
B2
.
textContent
==
'O'
)
&&
(
C2
.
textContent
==
'O'
)){
alert
(
"EL GANADOR ES: O"
);
}
if
((
A3
.
textContent
==
'X'
)
&&
(
B3
.
textContent
==
'X'
)
&&
(
C3
.
textContent
==
'X'
)){
alert
(
"EL GANADOR ES: X"
);
}
else
if
((
A3
.
textContent
==
'O'
)
&&
(
B3
.
textContent
==
'O'
)
&&
(
C3
.
textContent
==
'O'
)){
alert
(
"EL GANADOR ES: O"
);
}
if
((
A1
.
textContent
==
'X'
)
&&
(
B2
.
textContent
==
'X'
)
&&
(
C3
.
textContent
==
'X'
)){
alert
(
"EL GANADOR ES: X"
);
}
else
if
((
A1
.
textContent
==
'O'
)
&&
(
B2
.
textContent
==
'O'
)
&&
(
C3
.
textContent
==
'O'
)){
alert
(
"EL GANADOR ES: O"
);
}
if
((
A3
.
textContent
==
'X'
)
&&
(
B2
.
textContent
==
'X'
)
&&
(
C1
.
textContent
==
'X'
)){
alert
(
"EL GANADOR ES: X"
);
}
else
if
((
A3
.
textContent
==
'O'
)
&&
(
B2
.
textContent
==
'O'
)
&&
(
C1
.
textContent
==
'O'
)){
alert
(
"EL GANADOR ES: O"
);
}
}
}
\ No newline at end of file
js/javaScript2.js
0 → 100644
View file @
88a90ac5
function
init
(){
var
turno
=
1
;
var
array
=
Array
(
3
);
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
){
array
[
i
]
=
Array
(
3
);
}
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
){
for
(
var
k
=
0
;
k
<
array
.
length
;
k
++
){
array
[
i
][
k
]
=
-
1
;
}
}
jug1
.
onclick
=
function
(){
var
nombre
=
prompt
(
"Ingresa nombre"
);
while
(
nombre
==
""
){
nombre
=
prompt
(
"Debe ingresa nombre"
);
}
jug1
.
textContent
=
nombre
;
}
jug2
.
onclick
=
function
(){
var
nombre
=
prompt
(
"Ingresa nombre"
);
while
(
nombre
==
""
){
nombre
=
prompt
(
"Debe ingresa nombre"
);
}
jug2
.
textContent
=
nombre
;
}
xo1
.
onclick
=
function
(){
if
(
xo1
.
textContent
!==
'X'
&&
xo1
.
textContent
!==
'O'
){
textContent
=
'X'
;
}
if
(
xo1
.
textContent
==
'X'
){
xo1
.
textContent
=
'O'
;
}
else
{
xo1
.
textContent
=
'X'
;
}
}
xo2
.
onclick
=
function
(){
if
(
xo2
.
textContent
!==
'X'
&&
xo2
.
textContent
!==
'O'
){
xo2
.
textContent
=
'X'
;
}
if
(
xo2
.
textContent
==
'X'
){
xo2
.
textContent
=
'O'
;
}
else
{
xo2
.
textContent
=
'X'
;
}
}
comenzar
.
onclick
=
function
(){
var
val
=
true
;
while
(
jug1
.
textContent
==
""
){
alert
(
"Jugador 1 debe ingresar un nombre"
);
val
=
false
;
break
;
}
while
(
jug2
.
textContent
==
""
){
alert
(
"Jugador 2 debe ingresar un nombre"
);
val
=
false
;
break
;
}
while
(
xo1
.
textContent
!==
'X'
&&
xo1
.
textContent
!==
'O'
){
alert
(
"Jugador 1 debe escoger X o O"
);
val
=
false
;
break
;
}
while
(
xo2
.
textContent
!==
'X'
&&
xo2
.
textContent
!==
'O'
){
alert
(
"Jugador 2 debe escoger X o O"
);
val
=
false
;
break
;
}
while
(
xo1
.
textContent
==
xo2
.
textContent
){
alert
(
"Jugador 2 debe escoger distinta opcion a jugador 1"
);
val
=
false
;
break
;
}
if
(
val
==
true
){
inicio
();
}
}
function
inicio
(){
A1
.
onclick
=
function
(){
if
(
turno
==
1
){
A1
.
textContent
=
'X'
;
array
[
0
][
0
]
=
1
;
}
else
{
A1
.
textContent
=
'O'
;
array
[
0
][
0
]
=
2
;
}
analizar
();
cambiarTurno
();
}
A2
.
onclick
=
function
(){
if
(
turno
==
1
){
A2
.
textContent
=
'X'
;
array
[
0
][
1
]
=
1
;
}
else
{
A2
.
textContent
=
'O'
;
array
[
0
][
1
]
=
2
;
}
analizar
();
cambiarTurno
();
}
A3
.
onclick
=
function
(){
if
(
turno
==
1
){
A3
.
textContent
=
'X'
;
array
[
0
][
2
]
=
1
;
}
else
{
A3
.
textContent
=
'O'
;
array
[
0
][
2
]
=
2
;
}
analizar
();
cambiarTurno
();
}
B1
.
onclick
=
function
(){
if
(
turno
==
1
){
B1
.
textContent
=
'X'
;
array
[
1
][
0
]
=
1
;
}
else
{
B1
.
textContent
=
'O'
;
array
[
1
][
0
]
=
2
;
}
analizar
();
cambiarTurno
();
}
B2
.
onclick
=
function
(){
if
(
turno
==
1
){
B2
.
textContent
=
'X'
;
array
[
1
][
1
]
=
1
;
}
else
{
B2
.
textContent
=
'O'
;
array
[
1
][
1
]
=
2
;
}
analizar
();
cambiarTurno
();
}
B3
.
onclick
=
function
(){
if
(
turno
==
1
){
B3
.
textContent
=
'X'
;
array
[
1
][
2
]
=
1
;
}
else
{
B3
.
textContent
=
'O'
;
array
[
1
][
2
]
=
2
;
}
analizar
();
cambiarTurno
();
}
C1
.
onclick
=
function
(){
if
(
turno
==
1
){
C1
.
textContent
=
'X'
;
array
[
2
][
0
]
=
1
;
}
else
{
C1
.
textContent
=
'O'
array
[
2
][
0
]
=
2
;
}
analizar
();
cambiarTurno
();
}
C2
.
onclick
=
function
(){
if
(
turno
==
1
){
C2
.
textContent
=
'X'
;
array
[
2
][
1
]
=
1
;
}
else
{
C2
.
textContent
=
'O'
;
array
[
2
][
1
]
=
2
;
}
analizar
();
cambiarTurno
();
}
C3
.
onclick
=
function
(){
if
(
turno
==
1
){
C3
.
textContent
=
'X'
;
array
[
2
][
2
]
=
1
;
}
else
{
C3
.
textContent
=
'O'
;
array
[
2
][
2
]
=
2
;
}
analizar
();
cambiarTurno
();
}
function
cambiarTurno
(){
if
(
turno
==
1
){
turno
=
0
;
}
else
{
turno
=
1
;
}
}
}
function
analizar
(){
var
puntos
=
0
;
var
ganador
;
if
(
turno
==
1
){
puntos
=
3
;
ganador
=
'X'
;
}
else
{
puntos
=
6
;
ganador
=
'O'
;
}
if
(
filas
()){
alert
(
"EL GANADOR ES: "
+
ganador
);
}
if
(
columnas
()){
alert
(
"EL GANADOR ES: "
+
ganador
);
}
if
(
diagonales
()){
alert
(
"EL GANADOR ES: "
+
ganador
);
}
if
(
empate
()){
alert
(
"EMPATE"
);
}
function
empate
(){
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
){
for
(
var
k
=
0
;
k
<
array
.
length
;
k
++
){
if
(
array
[
i
][
k
]
==
-
1
){
return
false
;
}
}
}
return
true
;
}
function
filas
(){
var
sum1
=
0
;
var
sum2
=
0
;
var
sum3
=
0
;
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
){
sum1
+=
array
[
0
][
i
];
sum2
+=
array
[
1
][
i
];
sum3
+=
array
[
2
][
i
];
}
if
(
sum1
==
puntos
){
return
true
;
}
else
if
(
sum2
==
puntos
){
return
true
;
}
else
if
(
sum3
==
puntos
){
return
true
;
}
else
{
return
false
;
}
}
function
columnas
(){
var
sum1
=
0
;
var
sum2
=
0
;
var
sum3
=
0
;
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
){
sum1
+=
array
[
i
][
0
];
sum2
+=
array
[
i
][
1
];
sum3
+=
array
[
i
][
2
];
}
if
(
sum1
==
puntos
){
return
true
;
}
else
if
(
sum2
==
puntos
){
return
true
;
}
else
if
(
sum3
==
puntos
){
return
true
;
}
else
{
return
false
;
}
}
function
diagonales
(){
var
sum1
=
0
;
var
sum2
=
0
;
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
){
sum1
+=
array
[
i
][
i
];
}
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
){
sum2
+=
array
[
i
][(
array
.
length
-
1
)
-
i
];
}
if
(
sum1
==
puntos
){
return
true
;
}
else
if
(
sum2
==
puntos
){
return
true
;
}
else
{
return
false
;
}
}
}
}
\ No newline at end of file
tateti.html
0 → 100644
View file @
88a90ac5
<!DOCTYPE html>
<html
lang=
"es"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
TATETI
</title>
<link
rel=
"stylesheet"
href=
"css/styles.css"
>
</head>
<body
onload=
"init()"
>
<script
src=
"js/javaScript2.js"
></script>
<header>
<h1>
TA-TE-TI
</h1>
</header>
<main>
<table>
<thead>
<tr>
<td><button
id=
"jug1"
class=
"estboton"
>
JUGADOR 1
</button></td>
<td><button
id=
"xo1"
class=
"XO"
>
</button></td>
</tr>
<tr>
<td><button
id=
"jug2"
class=
"estboton"
>
JUGADOR 2
</button></td>
<td><button
id=
"xo2"
class=
"XO"
>
</button></td>
</tr>
<tr>
<td><button
id=
"comenzar"
class=
"estboton com"
>
COMENZAR
</button></td>
</tr>
</thead>
<tbody>
<tr>
<td><button
id=
"A1"
>
</button></td>
<td><button
id=
"A2"
>
</button></td>
<td><button
id=
"A3"
>
</button></td>
</tr>
<tr>
<td><button
id=
"B1"
>
</button></td>
<td><button
id=
"B2"
>
</button></td>
<td><button
id=
"B3"
>
</button></td>
</tr>
<tr>
<td><button
id=
"C1"
>
</button></td>
<td><button
id=
"C2"
>
</button></td>
<td><button
id=
"C3"
>
</button></td>
</tr>
</tbody>
</table>
</main>
</body>
</html>
\ 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