pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

epitaph64 private pastebin - collaborative debugging tool What's a private pastebin?


Posted by Epitaph64 on Sun 14 Jun 00:13
report abuse | download | new post

  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package bytemasking;
  7.  
  8. /**
  9.  *
  10.  * @author Walter
  11.  */
  12. public class Main {
  13.  
  14.     /* Player Properties by Bit
  15.      * 64 - Is the player alive
  16.      * 32 - Is the player male
  17.      * 16 & 8 - Is the player a Warrior, Rogue, Mage, or Druid
  18.      *  ( 1 is Warrior, 2 is Rogue, 3 is Mage, 4 is Druid )
  19.      * 4, 2 & 1 - What is the player's level between 1 and 8
  20.      */
  21.    
  22.     public static void main(String[] args)
  23.     {
  24.         for (int i = 0; i < 5; i++)
  25.         {
  26.             System.out.println(getPlayerDescription((byte) (Math.random() * 127)));
  27.         }
  28.     }
  29.  
  30.     public static String getPlayerDescription(byte playerData)
  31.     {
  32.         boolean playerAlive = false;
  33.         boolean playerMale = false;
  34.         int playerClass = 0;
  35.         int playerLevel = 0;
  36.         if ((playerData & 64) != 0)
  37.         {
  38.             playerAlive = true;
  39.         }
  40.         if ((playerData & 32) != 0)
  41.         {
  42.             playerMale = true;
  43.         }
  44.         if ((playerData & 16) != 0)
  45.         {
  46.             playerClass += 2;
  47.         }
  48.         if ((playerData & 16) != 0)
  49.         {
  50.             playerClass += 1;
  51.         }
  52.         playerLevel += (playerData &= 7) + 1;
  53.         String playerDescription = "";
  54.         playerDescription += "The player is a level " + playerLevel;
  55.         String playerClassName = "Citizen";
  56.         switch(playerClass)
  57.         {
  58.             case 0:
  59.             {
  60.                 playerClassName = "Warrior";
  61.                 break;
  62.             }
  63.             case 1:
  64.             {
  65.                 playerClassName = "Rogue";
  66.                 break;
  67.             }
  68.             case 2:
  69.             {
  70.                 playerClassName = "Mage";
  71.                 break;
  72.             }
  73.             case 3:
  74.             {
  75.                 playerClassName = "Druid";
  76.                 break;
  77.             }
  78.         }
  79.         playerDescription += " " + playerClassName + " ";
  80.         if (playerMale)
  81.         {
  82.             playerDescription += "Male who is ";
  83.         }
  84.         else
  85.         {
  86.             playerDescription += "Female who is ";
  87.         }
  88.         if (playerAlive)
  89.         {
  90.             playerDescription += "Alive.";
  91.         }
  92.         else
  93.         {
  94.             playerDescription += "Dead.";
  95.         }
  96.         return playerDescription;
  97.     }
  98.  
  99. }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post