Advertisement
Guest User

Untitled

a guest
May 28th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. package It.uniroma3.diadia.comandi;
  2.  
  3. import It.uniroma3.diadia.Partita;
  4. import It.uniroma3.diadia.attrezzi.Attrezzo;
  5.  
  6. public class ComandoRegalo implements Comando {
  7. private String nomeAttrezzo;
  8. private String messaggio;
  9.  
  10. @Override
  11. public String esegui(Partita partita) {
  12.  
  13. if(this.getParametro() == null){
  14. return "che cosa vuoi regalare?";
  15.  
  16. }
  17. if(!partita.getGiocatore().getBorsa().hasAttrezzo(getParametro())){
  18. return "Non hai un attrezzo simile!";
  19.  
  20. }
  21. if(partita.getStanzaCorrente().getPersonaggio() != null){
  22. Attrezzo dono = partita.getGiocatore().getBorsa().getAttrezzo(nomeAttrezzo);
  23. this.messaggio = partita.getStanzaCorrente().getPersonaggio().riceviRegalo(dono, partita);
  24. return this.messaggio;
  25. }
  26. else return "Non c'e' nessuno in questa stanza!";
  27. }
  28.  
  29. @Override
  30. public void setParametro(String parametro) {
  31. this.nomeAttrezzo = parametro;
  32.  
  33. }
  34.  
  35. @Override
  36. public String getNome() {
  37.  
  38. return "regala";
  39. }
  40.  
  41. @Override
  42. public String getParametro() {
  43. return this.nomeAttrezzo;
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement