added all needed subclasses, worked on Ghost classes.
This commit is contained in:
parent
b053561dfc
commit
f2c1cbc17c
@ -1,4 +1,9 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||||
|
|
||||||
public class Ghost extends Passenger {
|
public class Ghost extends Passenger {
|
||||||
|
protected boolean isOG; //true if the Ghost is the original ghost.
|
||||||
|
|
||||||
|
public boolean getIsOG() {
|
||||||
|
return isOG;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,8 +2,16 @@ package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
|||||||
|
|
||||||
public class GhostNPC extends Ghost{
|
public class GhostNPC extends Ghost{
|
||||||
|
|
||||||
public GhostNPC(int position, String name) {
|
/**
|
||||||
|
* 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.
|
||||||
|
* @param isOG true if the ghost is the original ghost.
|
||||||
|
*/
|
||||||
|
public GhostNPC(int position, String name, boolean isOG) {
|
||||||
|
this.isOG = isOG;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
this.sock = null;
|
||||||
isGhost = true;
|
isGhost = true;
|
||||||
isPlayerCharacter = false;
|
isPlayerCharacter = false;
|
||||||
kickedOff = false;
|
kickedOff = false;
|
||||||
|
|||||||
@ -0,0 +1,25 @@
|
|||||||
|
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||||
|
|
||||||
|
import java.net.Socket;
|
||||||
|
|
||||||
|
public class GhostPlayer extends Ghost{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
* @param isOG true if the ghost is the original ghost.
|
||||||
|
*/
|
||||||
|
public GhostPlayer(int position, String name, Socket sock, boolean isOG) {
|
||||||
|
this.position = position;
|
||||||
|
this.sock = sock;
|
||||||
|
this.isOG = isOG;
|
||||||
|
isGhost = true;
|
||||||
|
isPlayerCharacter = true;
|
||||||
|
kickedOff = false;
|
||||||
|
if (name == null) {
|
||||||
|
this.name = "Human Nr. " + position;
|
||||||
|
} else this.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||||
|
|
||||||
|
public class Human extends Passenger {
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||||
|
|
||||||
|
public class HumanNPC extends Human {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||||
|
|
||||||
|
public class HumanPlayer extends Human{
|
||||||
|
}
|
||||||
@ -1,13 +1,14 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||||
|
|
||||||
|
import java.net.Socket;
|
||||||
|
|
||||||
public class Passenger {
|
public class Passenger {
|
||||||
protected int position; //the player's Cabin number (1 to 6)
|
protected int position; //the player's Cabin number (1 to 6)
|
||||||
protected String name; //the player's Name
|
protected String name; //the player's Name
|
||||||
protected Boolean isGhost; //boolean regarding if the player is a ghost. Could probably be removed since ghost is a subclass but I'm keeping it in.
|
protected Boolean isGhost; //boolean regarding if the player is a ghost. Could probably be removed since ghost is a subclass but I'm keeping it in.
|
||||||
protected Boolean isPlayerCharacter; //same here
|
protected Boolean isPlayerCharacter; //same here
|
||||||
protected Boolean kickedOff; //true if the player has been voted off.
|
protected Boolean kickedOff; //true if the player has been voted off.
|
||||||
|
protected Socket sock; //the socket for the client associated with this Passenger, for NPCs, this can be null.
|
||||||
//todo: there needs to be some variable which keeps track of which client socket / clientThread / NPC thread this passenger is connected to?
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user