finished HumanPlayer class

This commit is contained in:
Jonas 2022-03-21 12:47:13 +01:00
parent f799f743dd
commit b6c21e2f3e
3 changed files with 39 additions and 3 deletions

View File

@ -19,11 +19,12 @@ public class GhostPlayer extends Ghost{
isPlayer = true;
kickedOff = false;
if (name == null) {
this.name = "Human Nr. " + position;
this.name = "Player Nr. " + position;
} else this.name = name;
}
public void send(String msg) {
//todo: pass message along to client.
//todo(Jonas): pass message along to client.
}
}

View File

@ -1,5 +1,20 @@
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
public class HumanNPC extends Human {
/**
* Creates a new GhostNPC. Should be used at game start or if a HumanNPC is turned into a ghost.
* @param position position on the train
* @param name player name. if null, then a default name is used.
*
*/
public HumanNPC(int position, String name) {
this.position = position;
this.sock = null;
isGhost = false;
isPlayer = false;
kickedOff = false;
if (name == null) {
this.name = "Robot Nr. " + position;
} else this.name = name;
}
}

View File

@ -1,4 +1,24 @@
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
import java.net.Socket;
public class HumanPlayer extends Human{
/**
* Creates a new GhostPlayer. Should be used at game start or if a HumanPlayer is turned into a ghost.
* @param position position on the train
* @param name name. if null, then a default name is used.
* @param sock the socket for the player.
*/
public HumanPlayer(int position, String name, Socket sock, boolean isOG) {
this.position = position;
this.sock = sock;
isGhost = false;
isPlayer = true;
kickedOff = false;
if (name == null) {
this.name = "Player Nr. " + position;
} else this.name = name;
}
}