Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
BootcampWebDia5
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
Cesar Giulano Gonzalez Maqueda
BootcampWebDia5
Commits
ed839fa5
Commit
ed839fa5
authored
Oct 22, 2021
by
Cesar Giulano Gonzalez Maqueda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validaciones varias agregadas
parent
12c5d5a8
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
13 deletions
+45
-13
twitter/src/twitter/BaseDeDatos.java
+3
-0
twitter/src/twitter/Dashboard.java
+6
-5
twitter/src/twitter/Seguimiento.java
+6
-0
twitter/src/twitter/TestTwitter.java
+21
-6
twitter/src/twitter/Tweet.java
+2
-2
twitter/src/twitter/Usuario.java
+7
-0
No files found.
twitter/src/twitter/BaseDeDatos.java
View file @
ed839fa5
...
...
@@ -10,6 +10,9 @@ public class BaseDeDatos {
/*
* Agrega un usuario si este no existe.
* */
if
(
usuario
==
null
){
return
;
}
for
(
Usuario
user:
usuarios
){
if
(
user
.
getNombreUsuario
().
equals
(
usuario
.
getNombreUsuario
())){
System
.
out
.
println
(
"ESTE NOMBRE DE USUARIO YA ESTA REGISTRADO"
);
...
...
twitter/src/twitter/Dashboard.java
View file @
ed839fa5
...
...
@@ -13,11 +13,13 @@ public class Dashboard {
ArrayList
<
Tweet
>
tweets
=
BaseDeDatos
.
getTweets
();
ArrayList
<
Usuario
>
usuarios
=
this
.
usuario
.
seguimiento
.
getSeguidos
();
int
count
=
0
;
int
index
=
0
;
for
(
Tweet
tweet:
tweets
){
int
cantidadTweets
=
tweets
.
size
()-
1
;
Tweet
tweet
;
for
(
int
i
=
cantidadTweets
;
i
>=
0
;
i
--){
tweet
=
tweets
.
get
(
i
);
if
(
usuarios
.
contains
(
tweet
.
getUsuario
())
||
tweet
.
getUsuario
()==
this
.
usuario
){
System
.
out
.
print
(
"\n---------------------"
);
System
.
out
.
print
(
"\n\t*id: "
+
i
ndex
+
"\n\tAutor: "
+
tweet
.
getUsuario
().
getNombreUsuario
()+
System
.
out
.
print
(
"\n\t*id: "
+
i
+
"\n\tAutor: "
+
tweet
.
getUsuario
().
getNombreUsuario
()+
"\n\tTexto: "
+
tweet
.
getText
());
System
.
out
.
print
(
"\n\tLikes: "
+
tweet
.
getNumeroFav
()+
"\tRts: "
+
tweet
.
getNumeroRt
());
if
(
tweet
.
getImageUrl
()!=
null
){
...
...
@@ -44,8 +46,7 @@ public class Dashboard {
return
;
}
}
System
.
out
.
println
(
"\n\n"
);
index
++;
}
System
.
out
.
println
(
"\n\n"
);
}
}
twitter/src/twitter/Seguimiento.java
View file @
ed839fa5
...
...
@@ -106,6 +106,12 @@ public class Seguimiento {
}
}
public
void
printBloqueados
(){
for
(
Usuario
user:
bloqueados
){
System
.
out
.
print
(
"\n\t--"
+
user
.
getNombreUsuario
());
}
}
public
ArrayList
<
Usuario
>
getSeguidores
()
{
return
seguidores
;
}
...
...
twitter/src/twitter/TestTwitter.java
View file @
ed839fa5
...
...
@@ -23,6 +23,7 @@ public class TestTwitter {
choice
=
in
.
nextInt
();
}
catch
(
Exception
e
){
System
.
out
.
println
(
"Entrada no validad"
);
in
.
reset
();
}
switch
(
choice
){
case
1
:
...
...
@@ -38,6 +39,7 @@ public class TestTwitter {
continuar
=
false
;
break
;
default
:
choice
=
0
;
System
.
out
.
println
(
"Eleccion no validad"
);
}
}
else
{
...
...
@@ -48,12 +50,13 @@ public class TestTwitter {
"4 - Bloqueados\n"
+
"0 - Cerrar Sesion\n"
+
"Entrada: "
);
int
choice3
=
0
;
try
{
choice
=
in
.
nextInt
();
choice
3
=
in
.
nextInt
();
}
catch
(
Exception
e
){
System
.
out
.
println
(
"Entrada no validad"
);
}
switch
(
choice
){
switch
(
choice
3
){
case
1
:
System
.
out
.
print
(
"\nDashboard: "
);
loggedUser
.
dashboard
.
verUltimosTweets
(
10
);
...
...
@@ -62,14 +65,14 @@ public class TestTwitter {
"\n3 - Retweetear"
+
"\n4 - Volver"
+
"\nEntrada: "
);
int
choice
3
=
0
;
int
choice
4
=
0
;
int
id
;
try
{
choice
3
=
in
.
nextInt
();
choice
4
=
in
.
nextInt
();
}
catch
(
Exception
e
){
System
.
out
.
println
(
"Eleccion no valida"
);
}
switch
(
choice
3
){
switch
(
choice
4
){
case
1
:
System
.
out
.
print
(
"\nID de Tweet a responder: "
);
id
=
in
.
nextInt
();
...
...
@@ -86,6 +89,7 @@ public class TestTwitter {
Tweet
.
retweetear
(
loggedUser
,
id
);
break
;
default
:
choice4
=
0
;
break
;
}
break
;
...
...
@@ -126,11 +130,13 @@ public class TestTwitter {
loggedUser
.
seguimiento
.
desbloquear
();
break
;
default
:
choice2
=
0
;
break
;
}
break
;
case
4
:
loggedUser
.
seguimiento
.
dejarDeSeguir
();
System
.
out
.
print
(
"\nBloqueados: "
);
loggedUser
.
seguimiento
.
printBloqueados
();
break
;
case
0
:
System
.
out
.
println
(
"Saliendo..."
);
...
...
@@ -138,6 +144,7 @@ public class TestTwitter {
break
;
default
:
System
.
out
.
println
(
"Eleccion no validad"
);
choice3
=
0
;
}
}
...
...
@@ -151,6 +158,14 @@ public class TestTwitter {
"correo"
+
i
,
new
Date
(),
new
Date
(),
"fotoUrl"
+
i
,
"descripcion"
+
i
,
i
%
2
==
0
));
}
for
(
int
i
=
0
;
i
<
10
;
i
++){
Usuario
user
=
BaseDeDatos
.
getUsuarioByUsername
(
"user"
+
i
);
for
(
int
j
=
0
;
j
<
5
;
j
++){
BaseDeDatos
.
addTweet
(
new
Tweet
(
user
,
"Test Tweet"
+(
i
*
5
+
j
),
"C:/path.test"
+(
i
*
5
+
j
)+
".jpg"
,
"https://link/test"
+(
i
*
5
+
j
)+
".com"
));
}
}
}
}
twitter/src/twitter/Tweet.java
View file @
ed839fa5
...
...
@@ -31,7 +31,7 @@ public class Tweet {
public
void
addLike
(
Usuario
usuario
){
for
(
Reaccion
reaccion:
reacciones
){
if
(
reaccion
.
getUsuario
()==
usuario
){
if
(
reaccion
.
getUsuario
()==
usuario
&&
reaccion
.
getTipoDeReaccion
().
equals
(
"LIKE"
)
){
System
.
out
.
println
(
"Ya diste like a esta publicacion"
);
return
;
}
...
...
@@ -46,7 +46,7 @@ public class Tweet {
public
void
addRt
(
Usuario
usuario
){
for
(
Reaccion
reaccion:
reacciones
){
if
(
reaccion
.
getUsuario
()==
usuario
){
if
(
reaccion
.
getUsuario
()==
usuario
&&
reaccion
.
getTipoDeReaccion
().
equals
(
"RT"
)
){
System
.
out
.
println
(
"Ya diste rt a esta publicacion"
);
return
;
}
...
...
twitter/src/twitter/Usuario.java
View file @
ed839fa5
package
twitter
;
import
java.util.Date
;
import
java.util.Locale
;
import
java.util.Objects
;
import
java.util.Scanner
;
import
java.util.regex.Pattern
;
public
class
Usuario
{
private
String
nombreUsuario
;
...
...
@@ -64,6 +66,7 @@ public class Usuario {
password
=
in
.
nextLine
();
System
.
out
.
print
(
"\nIngrese mail: "
);
mail
=
in
.
nextLine
();
if
(!
mailRegexCheck
(
mail
.
toUpperCase
()))
{
System
.
out
.
print
(
"\nFormato de Mail Incorrecto"
);
return
null
;}
System
.
out
.
print
(
"\nIngrese una descripcion: "
);
descripcion
=
in
.
nextLine
();
return
new
Usuario
(
username
,
password
,
mail
,
descripcion
);
...
...
@@ -130,4 +133,8 @@ public class Usuario {
public
boolean
isEsVerficado
()
{
return
esVerficado
;
}
private
static
boolean
mailRegexCheck
(
String
mail
){
return
Pattern
.
matches
(
"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$"
,
(
CharSequence
)
mail
);
}
}
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