Description The purpose of this assignment is to practice OOP with exceptions, generics, and collections. Your task is to create a set of classes for storing and managing a game catalog. This will...

1 answer below »
Hi, I have a new project with my class that involves the concepts of collections and generics. I attached the document with the specifications in it. There is a tester named P4Tester.jsbs which is not released yet from my instructor. To get full credit for this assignment my program has to pass the test cases given in the tester. When the tester is released I will attach it. Please test the completed program against the tester when I attach it. Thank you.


Description The purpose of this assignment is to practice OOP with exceptions, generics, and collections. Your task is to create a set of classes for storing and managing a game catalog. This will require an understanding of exceptions, generics, and the Java collections framework. Rules 1. You may import the following classes only: Collection, List, LinkedList, ArrayList, Set, HashSet, EnumSet, Arrays, Collections 2. Comment your code in javadoc style, especially any parts that is not obvious what you are doing. 3. Class fields should not be visible to other classes (unless otherwise noted). Create getter methods if necessary. 4. You may add your own methods, but they must be declared private. No additional fields are allowed. Grading The implementation of each class is worth the points specified at the beginning of each section. We will use both automated testing and manual inspection for the grading. Partial credit is possible but do not count on it if your code does not pass any tests. Hard coding to pass a certain set of test cases will receive an automatic zero. Testing You will be programming without a tester. The goal is to help you put more focus on writing logically correct programs instead of trying to pass certain tests only. Before using any tester, make sure you always compile and run your code without the tester to verify that there are no syntax errors. It is expected and helpful to write JUnit tests for running some basic tests on your own. From now on, place your debugging logic (static main methods) into a tester (e.g., P4Tester.java). On Windows: javac -cp .;junit-cs211.jar *.java java -cp .;junit-cs211.jar P4Tester On Mac or Linux: javac -cp .:junit-cs211.jar *.java java -cp .:junit-cs211.jar P4Tester Note: all the required classes and public members must exist for the grading tester to compile successfully. If you would like to test your code before you have implemented everything, make sure you have at least created the appropriate files and included the necessary members (fields and methods), even if their implementation is not complete. The grader will check the framework’s (collections) interface and class you use. Using classes without their interfaces will result on deductions. Tasks You must implement the following classes based on the specification provided. Be reminded that it is very important to follow these specs, otherwise your code will not compile/run with the tester. If you get errors or warnings from the compiler (e.g., erasure, abstract), do not ignore them. Game class This is an abstract class for representing different kinds of games (videogames, table-top games, etc.). All the games in the game catalog will be descendants of this class. It should implement the Comparable interface and specify the generic type for that interface so that Game can be compared to another Game. However, the details of the compareTo method should be left to subclasses. • puc: A string representing the Product Unique Code (PUC) of this game. Should have a getter (final) but no setter. • genres: A collection of strings representing the genres of this game. Should have a getter (final) but no setter. Such strings are unique within the collection. At least one genre must be provided. • getType(): A method that will return a string representing the type of this game. The details of this method should be left to subclasses. • Game(puc, genres): constructor with two arguments. Initializes private fields. • equals(obj): Overrides parent to return true if the given object is also a game, and their PUCs match. Otherwise, return false. • toString(): returns a string representation of this game. This should have the form "type: type, puc: puc, genres: genres", replacing the italicized placeholders with the string returned by getType(), puc, and genres values. Collections such as genres must be formatted using Arrays.deepToString(). Spacing, spelling, and capitalization are all important. Carefully implementing this method will allow for significant code reuse in subclasses. Format enumeration This is an enumeration representing the different formats a videogame can be distributed. It should have the following options: • CARTRIDGE • CD • MINIDISC • BLURAY • DOWNLOAD • CLOUD Videogame class This is an abstract subclass of Game that represents different types of videogames. It has a constructor, toString(), and provides an implementation for compareTo(). • publisher: A string with the name of the publisher. Should have a getter (final) but no setter. • director: A string with the name of the director. Should have a getter (final) but no setter. • formats: A collection of instances of the Format enum (described above). Should have a getter (final) but no setter. Such instances are unique within the collection. At least one format must be provided. • developers: A collection of strings with the names of the studios that developed the videogame. Should have a getter (final) but no setter. The order of developers indicates their contribution efforts, it must be preserved. • title: A string with the title of the videogame. Should have a getter (final) but no setter. • year: An integer representing the year the videogame was released. Should have a getter (final) but no setter. • Videogame (puc, genres, publisher, director, formats, developers, title, year): A constructor which sets the private fields. Must call the parent class constructor. • toString(): A string representation of this object. Has the form "publisher: publisher, director: director, formats: formats, developers: developers, title: title, year: year, " followed by the information given by its parent’s toString() method. Consider how inheritance can enable code reuse in this method. Collections such as formats and developers must be formatted using Arrays.deepToString(). • compareTo(argument): This method returns an integer value representing whether the instance given as an argument should be ordered before or after the calling instance. Negative numbers indicate the calling instance (this) should be ordered first. Positive numbers indicate the argument should be ordered first. Zero indicates that both instances have the same ordering. This method is what is used to sort collections in the collections framework. See the description of the sort() method in the GameCatalog class for how this method should be implemented. FirstPartyVideogame class This is a concrete class that inherits from VideoGame and represents first-party games. It overrides the constructor, and getType() methods. • getType(): Returns the string "First-Party". • FirstPartyVideogame(puc, genres, publisher, director, formats, developers, title, year): Calls the parent class constructor with the given arguments. SecondPartyVideogame class This is a concrete class that inherits from VideoGame and represents first-party games. It overrides the constructor, and getType() methods. • getType(): Returns the string "Second-Party". • SecondPartyVideogame(puc, genres, publisher, director, formats, developers, title, year): Calls the parent class constructor with the given arguments. ThirdPartyVideogame class This is a concrete class that inherits from VideoGame and represents first-party games. It overrides the constructor, and getType() methods. • getType(): Returns the string "Third-Party". • ThirdPartyVideogame(puc, genres, publisher, director, formats, developers, title, year): Calls the parent class constructor with the given arguments. ReleasedGame class This is a generic class, with two type specifications, that represents a mapping between keys and values. The first type can be any type, the second type must implement the Comparable interface and be comparable to other instances of the same type. The Releasedgame class itself should also implement Comparable, such that ReleasedGame instances are comparable to other ReleasedGame instances of the same kind (same generic type specifiers). The specific syntax for this class declaration should be: public class ReleasedGame > implements Comparable> • key: A reference of the first generic type. Should have a getter but no setter. • value: A reference of the second generic type. Should have a getter but no setter. • ReleasedGame(key, value): A constructor which sets the private data members. • equals(obj): Overrides the parent’s method to return true if the other object is also a ReleasedGame and has the same value. Otherwise, returns false. • compareTo(...): Returns the result of comparing the value field. If the generic specification is correct, there should be no need to cast anything. Searchable interface This interface contains a single method, matches, which returns true if a given game matches the criteria of this search. • matches(ReleasedGame): this is the method that will be called by the game catalog when searching. Items which return true will be included, items which return false will not be. GameSearcher class This is a concrete class that implements the Searchable interface, and represents a search with multiple terms, matching games which contain a given search strings among their fields. • searchTerms: a collection of strings to search for in each released game. No getters or setters. • GameSearcher(searchTerms): constructor that takes a collection of strings and should set searchTerms. • matches(ReleasedGame): returns true if the released game contains any of the search terms. Consider using the string returned by the toString method of the Game class. You may find the string method indexOf useful as well. GameCatalog class This class represents the catalog of released games. It contains a list of games and provides methods for games with the PUC it has been released with, returning a subset of items in the catalog given some search terms, and sorting the catalog. • catalog: A list of released games. A released game is an instance of the ReleasedGame class with the first type specified to be a string, and the second type specified to be Game (ReleasedGame). Should have a getter (final), no setter. • GameCatalog (): A default constructor which initializes the catalog. • add(puc, game): A method for adding games to the catalog. The first argument is a string, the second the game. This method should create a new ReleasedGame instance with the given data. • search(searchable): This method creates and returns a new list of released games. This new list should contain all released games from the catalog for which the given searchable's matches method returns true. • sort(): This method sorts (ascending) the field catalog according to the following rules: 1. First-party videogames come before second-party videogames, second-party videogames come before third-party videogames. 2. First-party videogames are sorted first by year, then by title. 3. Second-party videogames are sorted first by year, then by number of developers. 4. Third-party videogames
Answered 51 days AfterOct 29, 2022

Answer To: Description The purpose of this assignment is to practice OOP with exceptions, generics, and...

Manikandan answered on Nov 04 2022
43 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here