kurosen codding


Posts : 291 Join date : 2012-04-17
![[java] a simple compass class Empty](https://2img.net/i/empty.gif) | Subject: [java] a simple compass class Tue Oct 06, 2020 12:20 am | |
| - Code:
-
package chobit;
public class Compass { // input degress via external static var using setDegrees function private float degrees = 0.0f; private int direction = 0;
public void SetDegrees(float degress) { direction = (int) (degress / 45); }
public String getDirection() { switch (direction) { case 0: return "north"; case 1: return "northeast"; case 2: return "east"; case 3: return "southeast"; case 4: return "south"; case 5: return "southwest"; case 6: return "west"; case 7: return "northwest"; default: break; } return ""; } }
hadouken | |
|