Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ITEM CLASS
- import java.util.ArrayList;
- //fields
- public class Item
- {
- private String title;
- private int barcode;
- private boolean currentlyAvailable;
- private Rating rating;
- //constructors
- public Item(String theTitle, int theBarcode, Rating rating)
- {
- title = theTitle;
- barcode = theBarcode;
- currentlyAvailable = false;
- this.rating = rating;
- }
- //methods
- public Rating getRating()
- {
- return rating;
- }
- public int getBarcode()
- {
- return barcode;
- }
- public String getTitle()
- {
- return title;
- }
- public void setAvailability(boolean inStock)
- {
- currentlyAvailable = inStock;
- }
- public boolean getAvailibility()
- {
- return currentlyAvailable;
- }
- public void print()
- {
- System.out.println("Title:" + title);
- System.out.println("Barcode:" + barcode);
- }
- }
- //GAME CLASS
- public class VideoGame extends Item
- //fields
- {
- private int difficulty;
- private Platform platform;
- //constructors
- public VideoGame(String theTitle, int theDifficulty, int theBarcode, Platform platform, Rating rating)
- {
- super(theTitle, theBarcode, Rating rating);
- difficulty = theDifficulty;
- this.platform = platform;
- }
- //method
- public void print()
- {
- System.out.println("Title:" + getTitle());
- System.out.println("The Platform:" + platform);
- System.out.println("Game difficulty:" + difficulty);
- System.out.println("Barcode:" + getBarcode());
- }
- }
- //Rating enum
- public enum Rating
- {
- U("U"), PG("PG"), C7("C7"), C12("C12"), C15("C15"), C18("C18");
- private String ratingString;
- Rating(String ratingString)
- {
- this.ratingString = ratingString;
- }
- public String toString()
- {
- return ratingString;
- }
- }
- //Platform enum
- public enum Platform
- {
- PC("PC"), Gameboy("Gameboy"), PS3("PS3"), NintendoDS("NintendoDS"), Wii("Wii"), XBOX("XBOX");
- private String platformString;
- Platform(String platformString)
- {
- this.platformString = platformString;
- }
- public String toString()
- {
- return platformString;
- }
- }
Add Comment
Please, Sign In to add comment