Subject Computer Science Java Programming

Question

Objective:

- Develop a better understanding of OOP

- Become familiar with arrays in Java

- Develop a familiarity with bubble sort algorithm

Description:
- Create myIntArray class, that adds more functionality to the Java arrays.

Requirements:

Your myIntArray class should contain the following methods and characteristics:
- A default constructor myIntArray() that sets the size to 10 and initial values to 0.
- An alternative constructor myIntArray(int[] anArray) that allows the user to create an initial myIntArray that is equivalent to an array that is passed to the constructor.
- An alternative constructor myIntArray(int array_size) that sets the size of the array to array_size and initial values to 0.
- An alternative constructor myIntArray(int array_size , int init_val) that sets the size of the array to array_size and initial value to init_val.
- get(index) method that returns the value of array at the given index.
- If the index is out of the boundaries then exit the program.
- set(index, value) method that sets the value of the given index.
- If the index is out of the boundaries then exit the program.
- append(myIntArray anArray) method that appends anArray to the end of the current array.
- equals(myIntArray anArray) method that checks if the content of current array is the same as anArray.
- copy(myIntArray anArray) method that copies the content of the anArray to the calling myIntArray. This copying procedure will resize the calling myIntArray if needed.
- bubbleSort() that returns a new myIntArray with elements of the current array sorted in ascending order.
- printArray() method that prints the current array.

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 myIntArray {
public int[] array;

public myIntArray()
{
array = new int[10];
for(int i = 0; i < 10; i++)
array[i] = 0;
}

public myIntArray(int[] anArray)
{
array = anArray;...

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

Related Homework Solutions

Odd Numbers Problem in Java
Homework Solution
$10.00
Java
Programming
Computer Science
Mathematics
Integers
Odd Values
Even Values
Output
Input
Range
Loops
Conditions
Statements
Samples
Gradebook Using Java Programming
Homework Solution
$20.00
Java
Programming
Computer Science
Random Numbers
Scores
Students
Input
Output
Loops
Statements
Conditions
Average Values
Variables
Mathematics
Hangman Game Using Arrays
Homework Solution
$33.00
Computer Science
Game Development
Arrays
Programming
Java
Words
Codes
Letters
Hangman
Characters
Guessing
Input
Output
Drawing
Java Programming: User Defined Company
Homework Solution
$40.00
Java
Programming
Computer Science
Company
Stock Symbol
Stock Value
Constructor
Methods
Strings
Variables
Business
Finance
Economy
Hardware
Software
Arrays
Lists
Get help from a qualified tutor
Live Chats