All pastes #784070 Raw Edit

Player

public java v1 · immutable
#784070 ·published 2007-11-19 15:03 UTC
rendered paste body
public class Player {	int power;	int attackment;	String playerName;	boolean isDead = true;		public Player(String playerName, int power, int attackment) {		this.playerName = playerName;		this.attackment = attackment;		this.power = power;	}		public Player(String playerName) {		this.playerName = playerName;		this.attackment = 100;		this.power = 100;	}		public void adjPower(int adjustment) {		//System.out.println("[debug] adjustment = "+adjustment);		if (adjustment < 0) {			this.power += adjustment;		} else {			this.power += adjustment;		}	}		public int getpower() {		return power;	}		public String getPlayerName() {		return playerName;	}		public void attack(Player victim) {		System.out.println(getPlayerName() + " attack " + victim.getPlayerName());		int diff = Math.abs(this.power-victim.power);		if (diff==0) {			diff = 1;		}		victim.adjPower(-diff);		this.adjPower(+diff);	}		public boolean isDead() {		return (this.power <= 0);	}	}//770623