Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Provided Files: ContainerADT.pdf MemoryGame .java TileButton.java Testjava Lab Assigant: Part 1. Create a project with the following name YourLastNameLab2 Write an interface ContainerADT.java that describes

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
Provided Files: ContainerADT.pdf MemoryGame .java TileButton.java Testjava Lab Assigant: Part 1. Create a project with the following name YourLastNameLab2 Write an interface ContainerADT.java that describes a container that can hold different items. Use generics. The characteristics of the container are provided in the ContainerADT.pdf le which contains the description of methods that should be included in the interface. Part 2. Write an ArrayContainer.java class that implements the interface ContainerADT using an array. Use generics. Write two constructors: a constructor with no parameters that creates a container for 100 elements and a constructor that creates a container using the capacity received by parameter. When implementing method remove, make sure to deal with the empty spots in the array created by the remove operation. Part 3. Write an EmptyContainerException class. Part 4. Test the ArrayContainer class using the provided Test.java. You should add more java instructions to the provided Testjava application in order to test all methods from the array container. You may also run the memory game for fun. MemoryGame uses an ArrayContainer of Strings, If the memory game doesn't work properly go back and examine your code in the ArrayContainer class. Memory game uses import containerArrayContainer; instruction. Make sure that your package matches the package in the MemoryGamejava le. Hints: 1. Create a project for lab2 in NetBeans with container, application and exception packages. 2. Download Test.j ava, (MemoryGamejava and TileButtonjava - optional) to application package. 3. In the container folder create a ContainerADT interface and ArrayContainer class that implements the interface. 4. Use Generics in ContainerADT interface and in the ArrayContainer class 5. In the exceptions folder create EmptyContainerException class that extends Exception. This exceptions represents the situation in which the container is empty. 6. Read chapter 3 from your textbook. Chapter 3 has information about many of the concepts that will be important in this lab including Java Interfaces, Generics and Exceptions. Most of the questions you might have regarding this lab can be answered by reading chapter 3 and the documentation provided. 7.Comment your code using Javadoc comments Note on the Memory Game (optional): Memory game provided is common memory game played using many pairs of tiles. Each pair of tiles has the same symbol on one side and are blank on the other side. Initially all tiles are laid blank side up. The player turns over two tiles at a time. If the tiles match they are left face up with the matching symbols shown. If the tiles don't match they are turned back over to their blank side. The player continues to turn over pairs of tiles, attempting to create pairs by remembering the location of previously unmatched tiles. The game ends when all the tiles have been turned to show their symbols. Java application which assists a player in playing the memory game is provided for you in tile MemoryGamejava which usesTileButton.java. However, the source code for the collection (ArrayContainer) that store tiles has not been provided. Your task is to provide this collection. public interface ContainerADT Method Summary All Methods Instance Methods Abstract Methods Modifier and Type Method and Description void add (T element) Adds an element to the container, expanding the capacity of the container when necessary void clear () Clears the contents of the container boolean contains (T target) Returns true if the container contains the parameter otherwise it returns false boolean isEmpty () Returns true if this container contains no elements int maxSize () Returns the maximum size of the container T remove (T element) Removes an occurrence of the specified element from the container. T removeRandom () Removes a random element from the container. int size () Returns the number of elements in the container java . lang . String toString () Returns a string representation of the container Method Detail add void add (T element) Adds an element to the container, expanding the capacity of the container when necessary Parameters: element - element to be added removeRandom T removeRandom ( ) throws EmptyContainerExceptionRemoves a random element from the container. An EmptyContainerException is thrown if the container is empty. Returns: element from the bag Throws: EmpLyConLainerExcepLior'. - when container is empty I'BI'HDVE _ remove ('1' element} throws EmptyContainerException, java . util .NoSuchElementEx-ception Removes an occurrence of the specied element from the container. Parameters: element - to be removed from the container Returns: element from container specified by the parameter Throws: EmptyContainerException - when container is empty java.util.NoSuchElementException - when an element is not found clear void clear\" Clears the contents of the container contain 5 boolean contains(1' target) Returns true if the container contains the parameter otherwise it returns false Parameters: target element Returns: boolean to specify if the element already exists in the container isEmpty boolean isEmpty i) Returns true if this container contains no elements Returns: boolean value that indicates if container is empty or not maxSize int maxSize () Returns the maximum size of the container Returns: the size of the container size int size () Returns the number of elements in the container Returns: number of elements in the container toString java . lang . String toString () Returns a string representation of the container Overrides: toString in class java . lang . Object Returns: String

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

2 How the unemployment rate is calculated

Answered: 1 week ago