Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. package player;
  2. import bet.Bet;
  3.  
  4. public interface Player {
  5.  
  6. /**
  7. * Returns the name of the player.
  8. */
  9. public String getName();
  10.  
  11. /**
  12. * Returns the current balance of the player.
  13. */
  14. public int getBalance();
  15.  
  16. /**
  17. * Makes a new bet for the next game according to the player's
  18. * strategy.
  19. */
  20. public Bet makeBet();
  21.  
  22. /**
  23. * Adds the payout to the balance after winning a bet.
  24. */
  25. public void receivePayout(int payout);
  26.  
  27. }
  28.  
  29. package player;
  30. import bet.*;
  31.  
  32.  
  33. public class StraightPlayer implements Player {
  34.  
  35. String player;
  36. int balance;
  37. int bet;
  38. int favourite;
  39. Bet win;
  40.  
  41. public StraightPlayer(String name, int startBalance, int favourite) {
  42.  
  43. this.player = name;
  44. this.balance = startBalance;
  45. this.favourite = favourite;
  46. }
  47.  
  48. public int getFavourite() {
  49. return favourite;
  50. }
  51.  
  52. public String getName() {
  53. // TODO Auto-generated method stub
  54. return player;
  55. }
  56.  
  57. public int getFavourite() {
  58. return favourite;
  59. }
  60.  
  61. public int getBalance() {
  62. // TODO Auto-generated method stub
  63. if (balance <= 0) {
  64. return 0;
  65. }
  66. else {
  67. return balance;
  68. }
  69. }
  70.  
  71. public Bet makeBet() {
  72. // TODO Auto-generated method stub
  73. bet = 1;
  74. balance = balance - bet;
  75. return win; //incomplete
  76. }
  77.  
  78. public void receivePayout(int payout) {
  79. // TODO Auto-generated method stub
  80. balance = balance + win.getPayout();
  81. }
  82.  
  83. }
  84.  
  85. //method outside (Straight)Player
  86. if (int x == player.getFavourite) {
  87. stuff }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement