CS代考 COMP1110 Final Exam, Question 3

package comp1110.exam;

* COMP1110 Final Exam, Question 3
public class Q3ArrayList {

Copyright By PowCoder代写 加微信 powcoder

private static final int INITIAL_SIZE = 2;
private static final double GROWTH_FACTOR = 1.5;

T[] values = (T[]) new Object[INITIAL_SIZE];
int elements = 0;

* Add a value to the tail of the list.
* @param value The value to be added.
public void add(T value) {
/* Unimplemented. Q3 i) [7 Marks] */

* Remove the value at the specified index from the list.
* @param index
public void remove(int index) {
/* Unimplemented. Q3 ii) [7 Marks] */

* @param index
* @return The value at the specified index.
public T get(int index) {
if (index >= elements || index < 0) throw new IndexOutOfBoundsException(); return values[index]; * @return the current size of the list. public int size() { return elements; * Reverse the order of the elements of the list. public void reverse() { /* Unimplemented. Q3 iii) [6 Marks] */ * @return A string representation of the list. public String toString() { String rtn = ""; for (int i = 0; i < elements; i++) { rtn += ((i != 0) ? " " : "") + values[i]; return rtn; 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com