Advertisement
Guest User

Untitled

a guest
Feb 24th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. import java.util.*;
  2. public class Tutorial{
  3. //data members
  4. private int room = 0;
  5. private String user, output;
  6. private Player player;
  7. private Inventory inventory;
  8. private boolean tut = true;
  9. private boolean tut1 = true;
  10. private boolean gift = true;
  11. private Scanner scanner = new Scanner(System.in);
  12. //constructor
  13. public Tutorial(Player p, Inventory i){
  14. player = p;
  15. inventory = i;
  16. }
  17. //methods
  18. public String intro(){
  19. return "\nAh, yes! A young adventurer! Well, things around here aren't so difficult.\n" +
  20. "Most of us are farmers, but from time to time, an adventurer like you pops up!\n " +
  21. "At any time during the game, type 'info' to see your personal information.";
  22. } public String tut(){
  23. while(tut){
  24. System.out.println("\nType 'info' now.");
  25. user = scanner.next();
  26. if (user.equalsIgnoreCase("info")){
  27. output = "" + player.toString() + "\nVery good! Now that wasn't so hard!";
  28. tut = false;
  29. } else {
  30. output = "\nPlease type 'info' now.";
  31. }
  32. }
  33. return output;
  34. } public String tut1(){
  35. while(tut1){
  36. System.out.println("\nHow about typing in 'inventory'?");
  37. user = scanner.next();
  38. if(user.equalsIgnoreCase("inventory")){
  39. output = "" + inventory.toString() +
  40. "\nGreat! These are all of your items. You can buy more at the store.\n" +
  41. "Perfect! Almost done! The last thing to do is to choose an item. You'll have" +
  42. "\nplenty of opportunities to get these items later on in the game, but consider this\n" +
  43. "";
  44. tut1 = false;
  45. } else {
  46. output = "\nPlease type 'inventory' now.";
  47. }
  48. }
  49. return output;
  50. }
  51. public String gift(){
  52. while (gift){
  53. System.out.println("\nWhich item do you choose?\nSword\nPotions\nCoins");
  54. user = scanner.next();
  55. if(user.equalsIgnoreCase("sword")){
  56. inventory.gainSword(1);
  57. output = "\nGood choice. Off you go then!";
  58. gift = false;
  59. } else if(user.equalsIgnoreCase("potions")){
  60. inventory.gainPotion(10);
  61. output = "\nGood choice. Off you go then!";
  62. gift = false;
  63. } else if(user.equalsIgnoreCase("coins")){
  64. inventory.gainCoins(50);
  65. output = "\nGood choice. Off you go then!";
  66. gift = false;
  67. } else {
  68. output = "\nDon't be greedy! Choose from what you're offered.";
  69. }
  70. }
  71. return output;
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement