我正在编写一个程序,让两个坦克相互对抗。除了会结束游戏的火之外,我已经编写了所有方法。至今
public class Tank {
Tank() {
int xPos, yPos;
char direction;
boolean loaded = 0;
}
public void move(Tank currentPlayer) {
if (yPos<=4 && yPos>=0) {
if (xPos<=4 && xPos>=0) {
if (currentPlayer.direction == 'u') {
currentPlayer.yPos--;
}
if (currentPlayer.direction == 'd') {
currentPlayer.yPos++;
}
if (currentPlayer.direction == 'l') {
currentPlayer.xPos--;
}
if (currentPlayer.direction == 'r') {
currentPlayer.xPos++;
}
}
}
}
public void turn(boolean bool, Tank currentPlayer) {
if (currentPlayer.direction == 'u') {
currentPlayer.direction ='r';
}
if (currentPlayer.direction == 'd') {
currentPlayer.direction = 'l';
}
if (currentPlayer.direction == 'l') {
currentPlayer.direction ='u';
}
if (currentPlayer.direction == 'r') {
currentPlayer.direction ='d';
}
}
public void load(Tank currentPlayer) {
currentPlayer.loaded=true;
}
public int fire(Tank currentPlayer, Tank jim) {
// ???
}
}
我该如何完成我的程序?任何帮助,将不胜感激。