Guest User

Untitled

a guest
Apr 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. //ITEM CLASS
  2. import java.util.ArrayList;
  3. //fields
  4. public class Item
  5. {
  6. private String title;
  7. private int barcode;
  8. private boolean currentlyAvailable;
  9. private Rating rating;
  10.  
  11.  
  12. //constructors
  13. public Item(String theTitle, int theBarcode, Rating rating)
  14. {
  15. title = theTitle;
  16. barcode = theBarcode;
  17. currentlyAvailable = false;
  18. this.rating = rating;
  19. }
  20.  
  21. //methods
  22.  
  23. public Rating getRating()
  24. {
  25. return rating;
  26. }
  27. public int getBarcode()
  28. {
  29. return barcode;
  30. }
  31. public String getTitle()
  32. {
  33. return title;
  34. }
  35. public void setAvailability(boolean inStock)
  36. {
  37. currentlyAvailable = inStock;
  38. }
  39.  
  40. public boolean getAvailibility()
  41. {
  42. return currentlyAvailable;
  43. }
  44.  
  45. public void print()
  46. {
  47. System.out.println("Title:" + title);
  48. System.out.println("Barcode:" + barcode);
  49.  
  50. }
  51. }
  52.  
  53.  
  54.  
  55. //GAME CLASS
  56. public class VideoGame extends Item
  57.  
  58. //fields
  59. {
  60. private int difficulty;
  61. private Platform platform;
  62.  
  63. //constructors
  64. public VideoGame(String theTitle, int theDifficulty, int theBarcode, Platform platform, Rating rating)
  65. {
  66. super(theTitle, theBarcode, Rating rating);
  67. difficulty = theDifficulty;
  68. this.platform = platform;
  69. }
  70.  
  71. //method
  72. public void print()
  73. {
  74. System.out.println("Title:" + getTitle());
  75. System.out.println("The Platform:" + platform);
  76. System.out.println("Game difficulty:" + difficulty);
  77. System.out.println("Barcode:" + getBarcode());
  78. }
  79.  
  80. }
  81.  
  82.  
  83. //Rating enum
  84. public enum Rating
  85. {
  86. U("U"), PG("PG"), C7("C7"), C12("C12"), C15("C15"), C18("C18");
  87.  
  88. private String ratingString;
  89.  
  90. Rating(String ratingString)
  91. {
  92. this.ratingString = ratingString;
  93. }
  94.  
  95. public String toString()
  96. {
  97. return ratingString;
  98. }
  99. }
  100.  
  101.  
  102. //Platform enum
  103. public enum Platform
  104. {
  105. PC("PC"), Gameboy("Gameboy"), PS3("PS3"), NintendoDS("NintendoDS"), Wii("Wii"), XBOX("XBOX");
  106.  
  107. private String platformString;
  108.  
  109. Platform(String platformString)
  110. {
  111. this.platformString = platformString;
  112. }
  113.  
  114. public String toString()
  115. {
  116. return platformString;
  117. }
  118. }
Add Comment
Please, Sign In to add comment