Advertisement
Guest User

Tile.hasConnectionTo

a guest
Mar 30th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. public boolean hasConnectionTo(Orientation neighbor){
  2.         Orientation counter = neighbor.findCounterpart();
  3.         switch(this.tileType){
  4.         case DEAD_END:
  5.             for(int i = 0; i < orientation.length; i++){
  6.                 if(orientation[i] == counter){
  7.                     return true;
  8.                 }
  9.             }
  10.             return false;
  11.         case BEND:
  12.             switch(orientation[0]){
  13.             case RIGHT:            
  14.                 if(counter == Orientation.RIGHT || counter == Orientation.DOWN){
  15.                     return true;
  16.                 }else
  17.                     return false;
  18.             case DOWN:
  19.                 if(counter == Orientation.LEFT || counter == Orientation.DOWN){
  20.                     return true;
  21.                 }else
  22.                     return false;
  23.             case UP:               
  24.                 if(counter == Orientation.RIGHT || counter == Orientation.UP){
  25.                     return true;
  26.                 }else
  27.                     return false;
  28.             default:
  29.                 if(counter == Orientation.LEFT || counter == Orientation.UP){
  30.                     return true;
  31.                 }else
  32.                     return false;
  33.             }
  34.         case TEE:
  35.             switch(orientation[0]){
  36.             case RIGHT:
  37.                 if(counter != Orientation.UP) return true;
  38.                 else return false;
  39.             case UP:
  40.                 if(counter != Orientation.LEFT) return true;
  41.                 else return false;
  42.             case LEFT:
  43.                 if(counter != Orientation.DOWN) return true;
  44.                 else return false;
  45.             default:
  46.                 if(counter != Orientation.RIGHT) return true;
  47.                 else return false;
  48.             }
  49.         case STRAIGHT:
  50.             for(int i = 0; i < orientation.length; i++){
  51.                 if(orientation[i] == counter){
  52.                     return true;
  53.                 }
  54.             }
  55.             return false;
  56.         case CROSS:
  57.             return true;
  58.         default:
  59.             return false;
  60.         }
  61.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement