Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1034905 // NESWDirection

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5072L/28K).

enum NESWDirection {
  north(0, -1),
  east(1, 0),
  south(0, 1),
  west(-1, 0);
  
  // cache values()
  static final selfType values[] = values();
  
  private final gettable int x;
  private final gettable int y;
  
  *(int *x, int *y) {}
  
  int index() { ret ordinal(); }
  
  NESWDirection plus(int i) {
    ret getNESWDirection(index()+i);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034905
Snippet name: NESWDirection
Eternal ID of this version: #1034905/4
Text MD5: ee7444e8f093c6020d7fe106e012a989
Transpilation MD5: 8fb0da31750bc1fedc94dae4dc5db3fd
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-14 17:59:00
Source code size: 372 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 116 / 205
Version history: 3 change(s)
Referenced in: #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167)