finished HumanPlayer class
This commit is contained in:
parent
f799f743dd
commit
b6c21e2f3e
@ -19,11 +19,12 @@ public class GhostPlayer extends Ghost{
|
|||||||
isPlayer = true;
|
isPlayer = true;
|
||||||
kickedOff = false;
|
kickedOff = false;
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
this.name = "Human Nr. " + position;
|
this.name = "Player Nr. " + position;
|
||||||
} else this.name = name;
|
} else this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void send(String msg) {
|
public void send(String msg) {
|
||||||
//todo: pass message along to client.
|
//todo(Jonas): pass message along to client.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,20 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||||
|
|
||||||
public class HumanNPC extends Human {
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,24 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||||
|
|
||||||
|
import java.net.Socket;
|
||||||
|
|
||||||
public class HumanPlayer extends Human{
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user