Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package jumpingalien.model;
- import java.util.Collection;
- import java.util.HashSet;
- import java.util.Set;
- public class School {
- public School(World world) throws Exception{
- if(world.SchoolSet.size()==10) {throw new Exception();}
- else{setWorld(world);}
- }
- public void removeAsSlime(Slime slime) throws Exception {
- if(slime.getSchool()==null || !(hasAsSlime(slime))) {throw new Exception();}//FIXME modelException lukt niet
- else{
- School.remove(slime);
- slime.setSchool(null);
- }
- }
- public Set<Object> School = new HashSet<Object>();
- /**
- *
- * @param slime
- * @post...
- * |School.contains(slime)
- */
- public void AddAsSlime(Slime slime)throws Exception {
- if((hasAsSlime(slime))|| slime.IdSet.contains(slime.getID())) {throw new Exception();}
- School.add(slime);
- }
- public void switchSchool(Slime slime) {
- // TODO Auto-generated method stub
- }
- public Collection<? extends Slime> getAllSlimes() {
- return null;
- }
- /**
- * @return
- * |School.contains(slime)
- */
- public boolean hasAsSlime(Slime slime) {return School.contains(slime);}
- /**
- * @post..
- * |new.World=null
- */
- public void terminateSchool() {setWorld(null);}
- private World currentWorld;
- /**
- *
- * @param world
- * @post..
- * |new.World=world
- */
- public void setWorld(World world) {
- currentWorld=world;
- }
- public void removeWorld() {
- currentWorld.removeGameObject(this);
- setWorld(null);
- }
- }
Add Comment
Please, Sign In to add comment