subject

Please make a Generic SortedArrayList that the data structure code will support instantiating a sorted array list of Characters, Integers, or Pokemon. will need to code the generic class with particular attention to detail, for they must make the contents of the structure Comparable. Not only will the data structure the students create support additional methods (e. g., size), but it will always keep its contents in their natural order. Thus, when someone adds the numbers 4, 7, and 1 to an empty SortedArrayList, it actually stores them as: 1, 4, 7. The smallest thing in the list is located at index position 0. The largest thing is at index position size()-1. The Comparable type guarantees that objects that implement the interface provide the compareTo() method. This method returns either a negative number, a positive number, or zero. The value it returns reflects the relation between the two objects. None of your solutions should actually implement a compareTo method. Instead, the Java solutions should use the method already on the objects it intends to store inside. In addition to maintaining sorted order at all times, this SortedArrayList automatically expands its capacity (not size) when it fills up. It also shrinks after it detects that it is mostly empty. When the driver attempts to add an item to the structure when its size is at capacity, rather than failing because there is insufficient room, the structure shall increase its capacity. To do so, it must allocate a new backing-array with the expanded capacity and then copy the contents of the old array into the new memory area. Students may use memcopy or System. arraycopy for this operation, or they may do so using a simple for loop. Required Public Methods:Constructors: The class must include a default constructor (zero arguments) and a constructor that accepts a single argument representing the initial capacity of the internal array. boolean add(E item)Inserts the item into the array. The sorted array increases the size of the structure by one and places the new item in its correct position. This may cause a shift in the array's existing contents as the data structure moves everything over to make room for the new item. int capacity()Returns the maximum possible number of items the data structure may store (the size of the fuel tank) at the backing-array's current size. void clear()Resets the data structure's size to zero. E get(int index)Returns, but does not remove, the value of the item stored at position index within the array. boolean isEmpty()Returns true if size() == 0 and false under all other conditions. E remove(int index)Returns the value of the item stored at position index in the array (assuming it is within bounds) and deletes the item from the array. This may cause the array contents to shift over to fill the hole left by the vacated item. int size()This method returns the number of items stored inside the data structure (how much fuel is in the tank).

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 17:30, glocurlsprinces
Rachel completed typing an official document with a word processing program. she wants to make sure that her document has no typographical errors. she also wants all headings to have the same font. which features in a word processing program should she use? rachel should use the feature in a word processing program to find typographical errors. she should apply to have uniform headings.
Answers: 1
image
Computers and Technology, 22.06.2019 22:20, kaiyerecampbell95
Pp 4.1 design and implement a class called sphere that contains instance data that represents the sphere’s diameter. define the sphere constructor to accept and initialize the diameter and include getter and setter methods for the diameter. include methods that calculate and return the volume and surface area of the sphere (see pp 3.5 for the formulas). include a tostring method that returns a one-line description of the sphere. create a driver class called multisphere, whose main method instantiates and updates several sphere objects.
Answers: 1
image
Computers and Technology, 22.06.2019 23:30, keviongardner
The next button in the review section shows the next available comment. next slide with no comment. previous comment. edited comment.
Answers: 1
image
Computers and Technology, 22.06.2019 23:50, Crull5999
List a few alternative options and input and output over the standerd keyboard and monitor. explain their functioning in details.
Answers: 2
You know the right answer?
Please make a Generic SortedArrayList that the data structure code will support instantiating a sort...

Questions in other subjects:

Konu
Mathematics, 25.05.2020 22:58
Konu
Mathematics, 25.05.2020 22:58