Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
UyTube_obligatorio_PdA
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Juan José Álvarez Pérez
UyTube_obligatorio_PdA
Commits
6bbe895b
Commit
6bbe895b
authored
6 years ago
by
JotaJota96
Browse files
Options
Downloads
Plain Diff
Merge entre JulioRama hacia pre_master
parents
b54e8b49
ddc035ea
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
UyTube_aplicacion/src/Logica/Clases/Video.java
+67
-11
67 additions, 11 deletions
UyTube_aplicacion/src/Logica/Clases/Video.java
with
67 additions
and
11 deletions
UyTube_aplicacion/src/Logica/Clases/Video.java
+
67
−
11
View file @
6bbe895b
...
...
@@ -21,10 +21,13 @@ public class Video {
private
String
categoria
;
private
int
cantLikes
=
0
;
private
int
cantDisLikes
=
0
;
private
Map
<
Integer
,
Valoracion
>
valoraciones
;
private
ArrayList
<
Valoracion
>
valoraciones
;
private
Map
<
Integer
,
Comentario
>
comentarios
;
private
static
int
idActual
=
1
;
public
Video
(){
}
/********************** Constructor *********************/
public
Video
(
int
_id
,
String
_nombre
,
String
_descripcion
,
Time
_duracion
,
Date
_fechaPublicacion
,
String
_urlVideoOriginal
,
String
_categoria
){
this
.
id
=
_id
;
...
...
@@ -34,20 +37,34 @@ public class Video {
this
.
fechaPublicacion
=
_fechaPublicacion
;
this
.
urlVideoOriginal
=
_urlVideoOriginal
;
this
.
categoria
=
_categoria
;
this
.
valoraciones
=
new
TreeMap
<
Integer
,
Valoracion
>();
this
.
valoraciones
=
new
ArrayList
<
Valoracion
>();
this
.
comentarios
=
new
TreeMap
<
Integer
,
Comentario
>();
}
/** Agregar un nuevo comentario **/
public
void
agregarComentario
(
DtComentario
dtComentario
,
Usuario
usuario
){
int
nuevoId
=
Comentario
.
getNuevoID
();
Comentario
nuevoComentario
=
new
Comentario
(
nuevoId
,
dtComentario
.
getFecha
(),
dtComentario
.
getTexto
(),
0
,
usuario
);
comentarios
.
put
(
nuevoId
,
nuevoComentario
);
}
/* Agregar un subcomentario a un comentario existente */
public
void
agregarComentario
(
int
idCom
,
DtComentario
dtComentario
,
Usuario
usuario
){
for
(
Map
.
Entry
<
Integer
,
Comentario
>
coment
:
comentarios
.
entrySet
())
{
if
(
coment
.
getValue
().
agregarSubComentario
(
idCom
,
dtComentario
,
usuario
)){
break
;
}
}
}
/* Agrega o midifica una valoración */
public
void
agregarModificarValoracion
(
DtValoracion
dtValoracion
,
Usuario
usuario
){
String
nickname
=
usuario
.
getNickname
();
for
(
Valoracion
val:
valoraciones
){
if
(
val
.
modificar
(
dtValoracion
,
nickname
)){
break
;
}
}
}
public
DtVideo
getDt
(){
...
...
@@ -55,22 +72,61 @@ public class Video {
}
public
ArrayList
<
DtComentario
>
listarComentarios
(){
// provisorio
return
new
ArrayList
();
ArrayList
<
DtComentario
>
listaComent
=
new
ArrayList
<
DtComentario
>();
for
(
Map
.
Entry
<
Integer
,
Comentario
>
coment
:
comentarios
.
entrySet
())
{
DtComentario
dtComent
=
new
DtComentario
(
coment
.
getValue
().
getId
(),
coment
.
getValue
().
getUsr
().
getNickname
(),
coment
.
getValue
().
getFecha
(),
coment
.
getValue
().
getTexto
(),
coment
.
getValue
().
getNivelSubComentario
());
listaComent
.
add
(
dtComent
);
}
return
listaComent
;
}
public
ArrayList
<
DtValoracion
>
listarValoraciones
(){
// provisorio
return
new
ArrayList
();
ArrayList
<
DtValoracion
>
listaValoraciones
=
new
ArrayList
<
DtValoracion
>();
for
(
Valoracion
val:
valoraciones
){
listaValoraciones
.
add
(
new
DtValoracion
(
val
.
getVal
(),
val
.
getUsr
().
getNickname
()));
}
return
listaValoraciones
;
}
public
void
modificar
(
DtVideo
dtVideo
){
if
(
dtVideo
==
null
){
throw
new
RuntimeException
(
"El DtVideo es vacío"
);
}
// Perdon julio pero no entendi nada xD
if
(
dtVideo
.
getNombre
()==
""
){
throw
new
RuntimeException
(
"El nombre no puede ser vacío"
);
}
if
(
dtVideo
.
getDescripcion
()
==
""
)
{
throw
new
RuntimeException
(
"La descripcion no puede ser vacía"
);
}
if
(
dtVideo
.
getFechaPublicacion
()
==
null
)
{
throw
new
RuntimeException
(
"La fecha no puede ser vacía"
);
}
if
(
dtVideo
.
getCategoria
()
==
""
)
{
throw
new
RuntimeException
(
"La categoria no puede ser vacía"
);
}
this
.
nombre
=
dtVideo
.
getNombre
();
this
.
descripcion
=
dtVideo
.
getDescripcion
();
this
.
duracion
=
dtVideo
.
getDuracion
();
this
.
fechaPublicacion
=
dtVideo
.
getFechaPublicacion
();
this
.
privacidad
=
dtVideo
.
getPrivacidad
();
this
.
categoria
=
dtVideo
.
getCategoria
();
}
/* Obtiene la valoracion que hizo un usuario */
public
DtValoracion
obtenerValoracion
(
String
nickname
){
// provisorio
for
(
Valoracion
val:
valoraciones
){
if
(
val
.
getUsr
().
getNickname
()
==
nickname
){
DtValoracion
dtValoracion
=
new
DtValoracion
(
val
.
getVal
(),
val
.
getUsr
().
getNickname
());
return
dtValoracion
;
}
}
return
new
DtValoracion
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment