Subject Computer Science Java Programming

Question

Objective:
1.Become familiar with the dynamic allocation of array storage
2.Become familiar with ArrayList

Description:
Create your myIntArrayList class that is functionally similar to the formal Java ArrayList class.

Requirements:
Your myIntArrayList should contain the following methods and characteristics:

*Should contain a default constructor myIntArrayList()
*Should contain an alternative constructor myIntArrayList(int[] anArray) that allows the user to create an initial myIntArrayList that is equivalent to an array that is passed to the constructor
◦Should contain an alternative constructor myIntArrayList(myIntArrayList anExample) that will create an intMyArrayList identical to one that is passed to it
◦Should contain an void add(int index, int value) method
◾Need to check for appropriate index. If index is outside of the array boundaries, then add at the beginning or the end
◦Should contain a int remove(int index) method
◾If the index is outside of the array boundaries, then remove the first or last element
◦ Should contain a myIntArrayList simpleSort() method that will return another myIntArrayList object with the contents of the current object sorted using an insertion sort.
◦Should contain a int get(int index) method
◾If index is out of boundary then return either the first or last element
◦Should contain an int indexOf(int value) method
◾Returns the index of the first occurance of value
◦ Should contain an boolean isEmpty() method
◦Should contain a int size() method
◦ Should contain a void clear() method that empties the myIntArryList
◦ Should contain a void print() method that prints all elements of the myIntArrayList in one row delimited by one space

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class myIntArrayList {
public int[] array;

public myIntArrayList()
{
array = new int[0];
}

public myIntArrayList(int[] anArray)
{
array = new int[anArray.length];
for(int i = 0; i < anArray.length; i++)
array[i] = anArray[i];...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Java Program: True/False Answers
Homework Solution
$30.00
Java
Programming
Computer Science
Lecturer
Weekly Texts
Students
True/False Answers
Scores
Tests
Questions
Validation
Variables
Loops
Conditions
Classes in Java Programming
Homework Solution
$20.00
Java
Programming
Coding
Classes
OOP
Instances
Variables
Constructor
Parameters
Loops
Strings
Integers
Conditions
Statements
Setters
Getters
Error Handling
Arrays in Programming Language Java
Homework Solution
$20.00
Java
Programming
Computer Science
Arrays
Integers
Random Numbers
Methods
Functions
Even Elements
Odd Elements
Prime Numbers
Minimum Values
Maximum Values
Average Values
Loops
Conditions
Statements
ArrayLoop in Java
Homework Solution
$40.00
Java
Programming
Codes
Algorithms
Computer Science
Statements
Variables
Loops
Input
Output
Integers
Strings
Arrays
Sum
Average
Product
Screen Message
Calculations
Elements
Get help from a qualified tutor
Live Chats