Question: public class ArrayClass extends java.lang.Object Description: Class wrapper for a Java array, with additional management operations Note: Maintains a capacity value for maximum number of

public class ArrayClass

extends java.lang.Object

Description: Class wrapper for a Java array, with additional management operations

Note: Maintains a capacity value for maximum number of items that can be stored, and a size value for the number of valid or viable data items in the array

Implement the followings in ArrayClass:

Fields

private int

arrayCapacity

private int

arraySize

private static int

DEFAULT_CAPACITY

static int

FAILED_ACCESS

private int[]

localArray

Constructors

Constructor and Description

ArrayClass()

Default constructor, initializes array to default capacity (10)

ArrayClass(ArrayClass copied)

Copy constructor, initializes array to size and capacity of copied array, then copies only the elements up to the given size

ArrayClass(int capacity)

Initializing constructor, initializes array to specified capacity

ArrayClass(int capacity, int size, int fillValue)

Initializing constructor, initializes array to specified capacity, size to specified value, then fills all elements with specified size value

Method Summary

All MethodsInstance MethodsConcrete Methods

Modifier and Type

Method and Description

int

accessItemAt(int accessIndex)

Accesses item in array at specified index if index within array size bounds

boolean

appendItem(int newValue)

Appends item to end of array, if array is not full, e.g., no more values can be added

void

clear()

Clears array of all valid values by setting array size to zero, values remain in array but are not accessible

int

getCurrentCapacity()

Description: Gets current capacity of array

int

getCurrentSize()

Description: Gets current size of array

boolean

insertItemAt(int insertIndex, int newValue)

Description: Inserts item to array at specified index if array is not full, e.g., no more values can be added

boolean

isEmpty()

Tests for size of array equal to zero, no valid values stored in array

boolean

isFull()

Tests for size of array equal to capacity, no more values can be added

int

removeItemAt(int removeIndex)

Description: Removes item from array at specified index if index within array size bounds

boolean

resize(int newCapacity)

Description: Resets array capacity, copies current size and current size number of elements

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!