Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. package sd3cw1;
  2. public interface Strategy {
  3.  
  4. boolean CheckSpace(int SpaceNum);
  5.  
  6. }
  7.  
  8.  
  9.  
  10.  
  11. package sd3cw1;
  12.  
  13. public class PassiveStrategy implements Strategy {
  14.  
  15. import sd3cw1.Strategy;
  16.  
  17. @Override
  18. public boolean CheckSpace(int SpaceNum) {
  19. //insert code for passive encounters
  20. }
  21.  
  22. }
  23.  
  24.  
  25.  
  26.  
  27. package sd3cw1;
  28.  
  29. import sd3cw1.Strategy;
  30.  
  31. public class AggressiveStrategy implements Strategy {
  32.  
  33. @Override
  34. public boolean CheckSpace(int SpaceNum) {
  35. //insert code for aggressive encounters
  36. }
  37.  
  38. }
  39. }
  40.  
  41.  
  42.  
  43.  
  44. package sd3cw1;
  45.  
  46. import sd3cw1.Strategy;
  47.  
  48. public class Context {
  49.  
  50. int SpaceNum;
  51. Strategy strategy;
  52.  
  53. public Context(int SpaceNum, Strategy strategy) {
  54. this.SpaceNum = SpaceNum;
  55. this.strategy = strategy;
  56. }
  57.  
  58. public void setStrategy(Strategy strategy) {
  59. this.strategy = strategy;
  60. }
  61.  
  62. public int getSpaceNum() {
  63. return SpaceNum;
  64. }
  65.  
  66. public boolean getResult() {
  67. return strategy.CheckSpace(SpaceNum);
  68. }
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement