Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

a. Did you express your anger verbally? Physically?

Answered: 1 week ago