Skip to content
Snippets Groups Projects
Droplet.java 706 B
Newer Older
  • Learn to ignore specific revisions
  • package nloc;
    
    public class Droplet {
      private Position position;
      private DropletType type;
    
      public Droplet(DropletType type, Position position) {
        this.position = position;
        this.type = type;
    
        this.position.getChannel().addDroplet(this);
    
      }
    
      public void move() {
        position.increment(this);
      }
    
      public DropletType getType() {
        return type;
      }
    
      public Position getPosition() {
        return position;
      }
    
    
      public void setPosition(Position position) {
        this.position.getChannel().removeDroplet(this);
        this.position = position;
        this.position.getChannel().addDroplet(this);
      }
    
      public boolean isInSink() {
        return this.position.getChannel() instanceof Sink; 
      }