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
deaa5298
Commit
deaa5298
authored
6 years ago
by
JotaJota96
Browse files
Options
Downloads
Patches
Plain Diff
cambios a comentario
parent
06a467dd
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
UyTube_aplicacion/src/Logica/Clases/Comentario.java
+17
-10
17 additions, 10 deletions
UyTube_aplicacion/src/Logica/Clases/Comentario.java
UyTube_aplicacion/src/Logica/main.java
+32
-1
32 additions, 1 deletion
UyTube_aplicacion/src/Logica/main.java
with
49 additions
and
11 deletions
UyTube_aplicacion/src/Logica/Clases/Comentario.java
+
17
−
10
View file @
deaa5298
...
...
@@ -15,6 +15,8 @@ public class Comentario {
private
ArrayList
<
Comentario
>
misComentario
;
public
Comentario
()
{
this
.
id
=
Comentario
.
getNuevoID
();
this
.
misComentario
=
new
ArrayList
();
}
public
Comentario
(
int
id
,
Date
fecha
,
String
texto
,
int
nivelSubComentario
,
Usuario
usr
)
{
...
...
@@ -70,19 +72,24 @@ public class Comentario {
this
.
usr
=
usr
;
}
@Override
public
String
toString
()
{
return
"Comentario{"
+
"id="
+
id
+
", fecha="
+
fecha
+
", texto="
+
texto
+
", nivelSubComentario="
+
nivelSubComentario
+
'}'
;
}
public
boolean
agregarSubComentario
(
int
idComPadre
,
DtComentario
dtC
,
Usuario
usr
){
if
(
this
.
id
==
idComPadre
){
Comentario
com
=
new
Comentario
();
com
.
setUsr
(
usr
);
com
.
setId
(
Comentario
.
getNuevoID
());
com
.
setFecha
(
dtC
.
getFecha
());
com
.
setTexto
(
dtC
.
getTexto
());
com
.
setNivelSubComentario
(
dtC
.
getNivelSubComentario
());
Comentario
com
=
new
Comentario
(
Comentario
.
getNuevoID
(),
dtC
.
getFecha
(),
dtC
.
getTexto
(),
this
.
nivelSubComentario
+
1
,
usr
);
this
.
misComentario
.
add
(
com
);
return
true
;
}
else
{
for
(
int
i
=
0
;
i
<
misComentario
.
size
();
i
++){
if
(
this
.
misComentario
.
get
(
i
).
agregarSubComentario
(
idComPadre
,
dtC
,
usr
)){
return
true
;
...
...
@@ -99,11 +106,11 @@ public class Comentario {
public
ArrayList
<
DtComentario
>
listarSubComentarios
(){
ArrayList
lsc
=
new
ArrayList
();
for
(
int
i
=
0
;
i
<
lsc
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
this
.
misComentario
.
size
();
i
++){
lsc
.
add
(
this
.
misComentario
.
get
(
i
).
getDT
());
lsc
.
addAll
(
this
.
misComentario
.
get
(
i
).
listarSubComentarios
());
}
return
new
ArrayList
()
;
return
lsc
;
}
}
This diff is collapsed.
Click to expand it.
UyTube_aplicacion/src/Logica/main.java
+
32
−
1
View file @
deaa5298
package
Logica
;
import
Logica.Clases.Comentario
;
import
Logica.Clases.Usuario
;
import
Logica.DataType.DtComentario
;
import
java.sql.Date
;
import
java.util.ArrayList
;
public
class
main
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Hola mundo"
);
/*Usuario u1 = new Usuario("nicku1", "email1", new Date(2019-1900,7,15), "c/imagenes/algo1.jpg", "1234", "carlos1", "perez1", null);
Usuario u2 = new Usuario("nicku2", "email2", new Date(2019-1900,7,15), "c/imagenes/algo2.jpg", "1234", "carlos2", "perez2", null);
Usuario u3 = new Usuario("nicku3", "email3", new Date(2019-1900,7,15), "c/imagenes/algo3.jpg", "1234", "carlos3", "perez3", null);
Usuario u4 = new Usuario("nicku4", "email4", new Date(2019-1900,7,15), "c/imagenes/algo4.jpg", "1234", "carlos4", "perez4", null);
Usuario u5 = new Usuario("nicku5", "email5", new Date(2019-1900,7,15), "c/imagenes/algo5.jpg", "1234", "carlos5", "perez5", null);
Comentario c1 = new Comentario(Comentario.getNuevoID(), new Date(2019-1900,7,15), "1: exelente video", 0, u1);
c1.agregarSubComentario(c1.getId(), new DtComentario(1, null,new Date(2019-1900,7,15), "sub_1_1: mas o menos", 1), u2);
c1.agregarSubComentario(c1.getId(), new DtComentario(1, null,new Date(2019-1900,7,15), "sub_1_2: mas o menos", 1), u3);
c1.agregarSubComentario(c1.getId(), new DtComentario(1, null,new Date(2019-1900,7,15), "sub_1_3: mas o menos", 1), u4);
c1.agregarSubComentario(c1.getId(), new DtComentario(1, null,new Date(2019-1900,7,15), "sub_1_sub_1_1: mas o menos", 2), u3);
ArrayList l = c1.listarSubComentarios();
for(int i=0;i<l.size();i++){
System.out.println(l.get(i).toString());
}*/
ArrayList
<
Integer
>
l
=
new
ArrayList
();
l
.
add
(
2
);
l
.
add
(
8
);
l
.
add
(
15
);
l
.
add
(
22
);
l
.
add
(
7
);
for
(
int
i
=
0
;
i
<
l
.
size
();
i
++){
System
.
out
.
println
(
l
.
get
(
i
));
}
}
}
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