Skip to content
Snippets Groups Projects
Commit 1b6b4717 authored by Alfa-J's avatar Alfa-J
Browse files

agrege throw a comentario y valoracion

parent 4ac631b3
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,12 @@ public class Comentario {
}
public Comentario(int id, Date fecha, String texto, int nivelSubComentario, Usuario usr) {
if(usr==null){
throw new RuntimeException("Usuario No puede ser null");
}
if(fecha==null){
throw new RuntimeException("Date No puede ser null");
}
this.id = id;
this.fecha = fecha;
this.texto = texto;
......@@ -46,6 +52,9 @@ public class Comentario {
}
public void setFecha(Date fecha) {
if(fecha==null){
throw new RuntimeException("Fecha No puede ser null");
}
this.fecha = fecha;
}
......@@ -69,16 +78,18 @@ public class Comentario {
return usr;
}
public void setUsr(Usuario usr) {
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(dtC==null){
throw new RuntimeException("DtComentario No puede ser null");
}
if(usr==null){
throw new RuntimeException("Usuario No puede ser null");
}
if (this.id == idComPadre) {
Comentario com = new Comentario(Comentario.getNuevoID(),
dtC.getFecha(),
......
......@@ -11,6 +11,9 @@ public class Valoracion {
}
public Valoracion(TipoValoracion val, Usuario usr) {
if(usr==null){
throw new RuntimeException("Usuario No puede ser null");
}
this.val = val;
this.usr = usr;
}
......@@ -26,16 +29,15 @@ public class Valoracion {
public Usuario getUsr() {
return usr;
}
public void setUsr(Usuario usr) {
this.usr = usr;
}
private DtValoracion getDT(){
DtValoracion dtV = new DtValoracion(this.val, this.usr.getNickname());
return dtV;
}
private DtValoracion getDT(String nickname){
if(nickname==null){
throw new RuntimeException("Nickname No puede ser null");
}
// si esta valoracion corresponde al usuario, devuelve su DT, sino null
if (nickname.equals(this.usr.getNickname())){
return this.getDT();
......@@ -44,6 +46,12 @@ public class Valoracion {
}
}
private boolean modificar(DtValoracion dtV, String nickname){
if(dtV==null){
throw new RuntimeException("DtValoracion No puede ser null");
}
if(nickname==null){
throw new RuntimeException("Nickname No puede ser null");
}
if (nickname.equals(this.usr.getNickname())){
this.val = dtV.getVal();
return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment