Advertisement
Guest User

SSPController

a guest
Oct 26th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. package p3;
  2.  
  3. public class SSPController {
  4.  
  5. private SSPViewer viewer;
  6. private SSPPlayer play;
  7. private String datorVapen;
  8. private SSPComputer computer;
  9.  
  10. // private rand.nextInt(3);
  11.  
  12. // Skaoa konstanser när man har int
  13.  
  14. public static int STEN = 0, SAX = 1, PÅSE = 2;
  15.  
  16. // Controller.STEN
  17.  
  18. public SSPController() {
  19.  
  20. }
  21.  
  22. public SSPController(SSPPlayer player, SSPViewer viewer, SSPComputer computer) {
  23. this.viewer = viewer;
  24. this.play = player;
  25. this.computer = computer;
  26. }
  27.  
  28. public void PlayerChoice(String choice) {
  29. // this.choice = choice;
  30. viewer.setVapen(choice);
  31.  
  32. computer.computerChoice();
  33.  
  34. play.setPlayerChoice(choice);
  35.  
  36. viewer.setComputerVapen(computer.getComputerCh());
  37.  
  38. whosPoints();
  39.  
  40. }
  41.  
  42. public void computerChoice() {
  43. System.out.println("Controller");
  44. viewer.setComputerVapen(datorVapen);
  45.  
  46. }
  47.  
  48. public void exitGame() {
  49. System.exit(0);
  50. }
  51.  
  52. public void newGame() {
  53. new SSPViewer(); /// Feellll
  54. }
  55.  
  56. public void whosPoints() {
  57.  
  58.  
  59. if (play.getPlayerChoice() == "STEN" && computer.getComputerCh() == "SAX") {
  60. play.setPlayerPoints(play.getPlayerPoints() + 1);
  61. viewer.setPlayerPoints(play.getPlayerPoints()); // MÄNNISKA
  62. } else if (play.getPlayerChoice() == "SAX" && computer.getComputerCh() == "PÅSE") {
  63. play.setPlayerPoints(play.getPlayerPoints() + 1);
  64. viewer.setPlayerPoints(play.getPlayerPoints()); // MÄNNISKA
  65. } else if (play.getPlayerChoice() == "PÅSE" && computer.getComputerCh() == "STEN") {
  66. play.setPlayerPoints(play.getPlayerPoints() + 1);
  67. viewer.setPlayerPoints(play.getPlayerPoints()); // MÄNNISKA
  68. } else if (computer.getComputerCh() == "STEN" && play.getPlayerChoice() == "SAX") {
  69. computer.setComputerPoints(computer.getComputerPoints() + 1); // DATOR
  70. viewer.setCompPoints(computer.getComputerPoints());
  71. } else if (computer.getComputerCh() == "SAX" && play.getPlayerChoice() == "PÅSE") {
  72. computer.setComputerPoints(computer.getComputerPoints() + 1); // DATOR
  73. viewer.setCompPoints(computer.getComputerPoints());
  74. } else if (computer.getComputerCh() == "PÅSE" && play.getPlayerChoice() == "STEN")
  75. computer.setComputerPoints(computer.getComputerPoints() + 1); // DATOR
  76. viewer.setCompPoints(computer.getComputerPoints());
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement