Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package p3;
- public class SSPController {
- private SSPViewer viewer;
- private SSPPlayer play;
- private String datorVapen;
- private SSPComputer computer;
- // private rand.nextInt(3);
- // Skaoa konstanser när man har int
- public static int STEN = 0, SAX = 1, PÅSE = 2;
- // Controller.STEN
- public SSPController() {
- }
- public SSPController(SSPPlayer player, SSPViewer viewer, SSPComputer computer) {
- this.viewer = viewer;
- this.play = player;
- this.computer = computer;
- }
- public void PlayerChoice(String choice) {
- // this.choice = choice;
- viewer.setVapen(choice);
- computer.computerChoice();
- play.setPlayerChoice(choice);
- viewer.setComputerVapen(computer.getComputerCh());
- whosPoints();
- }
- public void computerChoice() {
- System.out.println("Controller");
- viewer.setComputerVapen(datorVapen);
- }
- public void exitGame() {
- System.exit(0);
- }
- public void newGame() {
- new SSPViewer(); /// Feellll
- }
- public void whosPoints() {
- if (play.getPlayerChoice() == "STEN" && computer.getComputerCh() == "SAX") {
- play.setPlayerPoints(play.getPlayerPoints() + 1);
- viewer.setPlayerPoints(play.getPlayerPoints()); // MÄNNISKA
- } else if (play.getPlayerChoice() == "SAX" && computer.getComputerCh() == "PÅSE") {
- play.setPlayerPoints(play.getPlayerPoints() + 1);
- viewer.setPlayerPoints(play.getPlayerPoints()); // MÄNNISKA
- } else if (play.getPlayerChoice() == "PÅSE" && computer.getComputerCh() == "STEN") {
- play.setPlayerPoints(play.getPlayerPoints() + 1);
- viewer.setPlayerPoints(play.getPlayerPoints()); // MÄNNISKA
- } else if (computer.getComputerCh() == "STEN" && play.getPlayerChoice() == "SAX") {
- computer.setComputerPoints(computer.getComputerPoints() + 1); // DATOR
- viewer.setCompPoints(computer.getComputerPoints());
- } else if (computer.getComputerCh() == "SAX" && play.getPlayerChoice() == "PÅSE") {
- computer.setComputerPoints(computer.getComputerPoints() + 1); // DATOR
- viewer.setCompPoints(computer.getComputerPoints());
- } else if (computer.getComputerCh() == "PÅSE" && play.getPlayerChoice() == "STEN")
- computer.setComputerPoints(computer.getComputerPoints() + 1); // DATOR
- viewer.setCompPoints(computer.getComputerPoints());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement