Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Player
Monday, November 19th, 2007 at 8:03:14am MST 

  1. public class Player {
  2.         int power;
  3.         int attackment;
  4.         String playerName;
  5.         boolean isDead = true;
  6.        
  7.         public Player(String playerName, int power, int attackment) {
  8.                 this.playerName = playerName;
  9.                 this.attackment = attackment;
  10.                 this.power = power;
  11.         }
  12.        
  13.         public Player(String playerName) {
  14.                 this.playerName = playerName;
  15.                 this.attackment = 100;
  16.                 this.power = 100;
  17.         }
  18.        
  19.         public void adjPower(int adjustment) {
  20.                 //System.out.println("[debug] adjustment = "+adjustment);
  21.                 if (adjustment < 0) {
  22.                         this.power += adjustment;
  23.                 } else {
  24.                         this.power += adjustment;
  25.                 }
  26.         }
  27.        
  28.         public int getpower() {
  29.                 return power;
  30.         }
  31.        
  32.         public String getPlayerName() {
  33.                 return playerName;
  34.         }
  35.        
  36.         public void attack(Player victim) {
  37.                 System.out.println(getPlayerName() + " attack " + victim.getPlayerName());
  38.                 int diff = Math.abs(this.power-victim.power);
  39.                 if (diff==0) {
  40.                         diff = 1;
  41.                 }
  42.                 victim.adjPower(-diff);
  43.                 this.adjPower(+diff);
  44.         }
  45.        
  46.         public boolean isDead() {
  47.                 return (this.power <= 0);
  48.         }
  49.        
  50. }//770623       

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right
fantasy-obligation