battle programmers alliance
Would you like to react to this message? Create an account in a few clicks or log in to continue.

battle programming a forum for elite programmers with extreme will power to sharpen their skills
HomeGallerySearchRegisterLog in

 [java] a simple compass class

Go down 

Posts : 293
Join date : 2012-04-17

[java] a simple compass class Empty
PostSubject: [java] a simple compass class   [java] a simple compass class EmptyTue Oct 06, 2020 12:20 am


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";
      return "";

hadouken hadouken
Back to top Go down
[java] a simple compass class
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
battle programmers alliance :: battle programming alliance :: battle programming-
Jump to: