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

Binary Search Tree in Java
Homework Solution
$50.00
Computer Science
Programming
Java
Binary Search Tree
Sequences
Integer Values
Order
Traversals
Recursion
Commands
Predecessors
Successors
Statements
Functions
Nodes
Pyramid Using Asterisks in Java
Homework Solution
$30.00
Java
Programming
Codes
Algorithms
Computer Science
Statements
Variables
Loops
Input
Output
Integers
Strings
Asterisks
Symbols
Pyramid
Rows
Odd Numbers
Pythagorean Theorem in Java
Homework Solution
$13.00
Computer Science
Programming
Java
Pythagorean Theorem
Mathematics
Triangles
Sides
Angles
Equations
Statements
Variables
Parameters
Methods
Java Programming Problems
Homework Solution
$20.00
Java
Programming
Computer Science
File Management
Scripts
Input
Output
Keys
Arrays
Values
Samples
Lists
Hashes
Functions
Methods
Strings
Statements
Conditions
Loops
Sales Problems in Java
Homework Solution
$30.00
Computer Science
Programming
Java
Sales
Text Files
Prices
Products
Reading Strategy
Constructor
Methods
Classes
Variables
Statements
Numbers
Average Values
Class Diagrams
Testers
Parsing
Java Programming Problems: Expression Trees and AVL Trees
Homework Solution
$50.00
Java
Programming
Computer Science
Expression Trees
AVL Trees
Algorithms
Input
Output
Recursive Functions
Strings
Variables
Statements
Loops
Methods
Expressions
Objects
Classes
Operators
Nodes
Numbers
Get help from a qualified tutor
Live Chats