
Write a class MySortedArrayCollection that Inherit the SortedArrayCollection class show in screen shot and such that all the following methods are implemented in java, then write a driver program to test the methods
public String toString()
// Creates and returns a string that correctly represents the current collection.
public T smallest()
// Returns null if the collection is empty, otherwise returns the smallest element of the collection.
public int greater(T element)
// Returns a count of the number of elements e in the collection that are greater then element, that is such that e.compareTo(element) is > 0
public MySortedArrayCollection <T> combine (MySortedArrayCollection<T>other)
// Creates and returns a new SortedArrayCollection object that is a combination of this object and the argument object.
public T []toArray()
// Returns an array containing all of the elements of the collection.
public void clear()
// Removes all elements.
public boolean equals(Object o)
// Takes an Object argument, returning true if it is equal to the current collection and false otherwise
public boolean addAll(MySortedArrayCollection<T>c)
// Takes a MySortedArrayCollection argument and adds its contents to the current collection; returns a boolean indicating success or failure.
public boolean retainAll(MySortedArrayCollection<T>c)
// Takes a MySortedArrayCollection argument and removes any elements from the current collection that are not in the argument collection; returns a boolean indicating success or failure.
public void removeAll(MySortedArrayCollection<T>c){
// Takes a MySortedArrayCollection argument and removes any elements from the current collection that are also in the argument collection.


Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- Write program in javaarrow_forwardThe play method in the Player class of the craps game plays an entire game without interaction with the user. Revise the Player class so that its user can make individual rolls of the dice and view the results after each roll. The Player class no longer accumulates a list of rolls, but saves the string representation of each roll after it is made. Add new methods rollDice, getNumberOfRolls, isWinner, and isLoser to the Player class. The last three methods allow the user to obtain the number of rolls and to determine whether there is a winner or a loser. The last two methods are associated with new Boolean instance variables (winner and loser respectively). Two other instance variables track the number of rolls and the string representation of the most recent roll (rollsCount and roll). Another instance variable (atStartup) tracks whether or not the first roll has occurred. At instantiation, the roll, rollsCount, atStartup, winner, and loser variables are set to their appropriate…arrow_forwardBuild two classes (Fraction and FractionCounter) and a Driver for use in counting the number of unique fractions read from a text file. We’ll also reuse the ObjectList class we built in lab to store our list of unique FractionCounters, instead of directly using arrays or the ArrayList. Remember NO DECIMALS! Handle input of any length Introduction Your project is to read in a series of fractions from a text file, which will have each line formatted as follows: “A/B”. A sample text file is listed below, and the purpose of your program is to read in one line at a time and build a Fraction object from A and B. For each unique Fraction seen, your program will create a FractionCounter object used to track the number of occurrences of that specific fraction. When all the input is consumed, your program will print out its ObjectList of unique FractionCounters, which should report the fraction and its count – see output below. You can assume no blank lines or misleading characters; see…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





