Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fp.grados.tipos;
- import java.util.HashSet;
- import java.util.Set;
- import fp.grados.excepciones.ExcepcionDespachoNoValido;
- public class DespachoImpl extends EspacioImpl implements Despacho {
- public Set<Profesor> profesores;
- public DespachoImpl(TipoEspacio tipo, String nombre, Integer capacidad,
- Integer planta, Set<Profesor> profesores){
- super(tipo, nombre, capacidad, planta);
- tipo = TipoEspacio.OTRO;
- checkNumeroProfesores(profesores, capacidad);
- this.profesores = profesores;
- checkTipo(tipo);
- }
- public DespachoImpl(TipoEspacio tipo, String nombre, Integer capacidad,
- Integer planta, Profesor profesor){
- super(tipo, nombre, capacidad, planta);
- tipo = TipoEspacio.OTRO;
- this.profesores = new HashSet<Profesor>();
- this.profesores.add(profesor);
- checkNumeroProfesores(profesores, capacidad);
- checkTipo(tipo);
- }
- public DespachoImpl(TipoEspacio tipo, String nombre, Integer capacidad,
- Integer planta){
- super(tipo, nombre, capacidad, planta);
- tipo = TipoEspacio.OTRO;
- profesores = new HashSet<Profesor>();
- }
- //Checks
- public void checkNumeroProfesores(Set<Profesor> p, Integer c) {
- if(p.size() > c){
- throw new ExcepcionDespachoNoValido("Capacidad de despacho superada");
- }
- }
- public void checkTipo(TipoEspacio tipo){
- if(!(tipo.equals(TipoEspacio.OTRO))){
- throw new ExcepcionDespachoNoValido("Tipo invalido de espacio");
- }
- }
- @Override
- public void setTipo(TipoEspacio t){
- throw new UnsupportedOperationException("No se debe cambiar el tipo de despacho");
- }
- public Set<Profesor> getProfesores() {
- return profesores;
- }
- @Override
- public String toString(){
- String s;
- s = super.toString() + profesores.toString();
- return s;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement