SlideShare a Scribd company logo
1 of 7
Download to read offline
Everything needs to be according to the instructions, thank you!
SUPPORTING CODE:
MyList.java
/**
This interface specifies the basic operations of any list-like object.
This interface contains a variation of the methods of the
standard java.util.List interface.
*/
public interface MyList {
/**
Adds an element at the end of the list.
*/
public void addToEnd(Object o);
/**
Inserts an element at the specified index
Throws NoSuchElementException if index is out of bounds.
*/
public void insertAt(int index, Object o);
/**
Removes the element at the specified index
Throws NoSuchElementException if index is out of bounds.
*/
public void removeAt(int index);
/**
Returns the element at the specified index
Throws NoSuchElementException if index is out of bounds.
*/
public Object getAt(int index);
/**
Returns the size of the list.
@return the number of elements in the list
*/
public int getSize();
/**
Returns a list iterator for this list.
@return a list iterator for this list
*/
public MyListIterator getIterator();
}
MyListIterator.java
/**
A list iterator allows access of a position in a list.
This interface contains a subset of the methods of the
standard java.util.ListIterator interface. The methods for
backward traversal are not included.
*/
public interface MyListIterator
{
/**
Moves the iterator past the next element.
@return the traversed element
*/
Object next();
/**
Tests if there is an element after the iterator
position.
@return true if there is an element after the iterator
position
*/
boolean hasNext();
}
Main.java
// you may use this file to write and run code to test your MyArrayList class
public class Main {
public static void main(String[] args) {
}
}
FILE THAT NEEDS THAT NEEDS CODE:
MyArrayList.java
// Complete the implementation of your MyArrayList class in this file
public class MyArrayList implements MyList {
// Implement the required fields and methods here
private int capacity = 8;
private Object[ ] array = new Object [capacity];
private int size = 0;
@Override
public void add(Object o) {
if (size >= capacity){
Object[] temp = new Object[2*array.length];
for(int i=0;i<size;++i){
temp[i] = array[i];
}
this.capacity = 2*array.length;
array = temp;
array[size++] = o;
return;
}
else
{
array[size++] = o;
}
}
@Override
public int size() {
return size;
}
@Override
public Object at(int index) {
if (index >= capacity)
return null;
else
return array[index];
}
@Override
public void insertAt(int index, Object o) {
if (index >= capacity)
return;
else
{
size++;
for (int x = size - 1; x > index; x--) {
array[x] = array[x - 1];
}
array[index] = o;
}
}
@Override
public void removeAt(int index) {
if (index >= size || size == 0)
return;
else {
Object e = array[index];
for (int x = index; x < this.array.length - 1; x++) {
array[x] = array[x + 1];
}
size--;
}
}
public void ensureCapacity(int minCapacity) {
}
public void trimToSize() {
ensureCapacity(size);
}
// Do not alter the code below
@Override
public MyListIterator getIterator() {
return new MyArrayListIterator();
}
private class MyArrayListIterator implements MyListIterator {
int currentIndex = -1;
@Override
public Object next() {
++currentIndex;
return storage[currentIndex];
}
@Override
public boolean hasNext() {
return currentIndex < size - 1;
}
}
}
You are not allowed to use any of the standard Java collection types (like ArrayList) for this
assignment. You may use simple arrays. Problem Description and Given Info For this
assignment you are given the following Java source code files: - MyListiterator. java (This file is
complete - make no changes to this file) - MyList. java (This file is complete - make no changes
to this file) - MyArraylist.java (You must complete this file) - Main.java (You may use this file
to write code to test your MyArrayList) You must complete the public class named MyArrayList
with fields and methods as defined below. Your MyArrayList will implement the MyList
interface that is provided in the myList. java file. Structure of the Fields As described by the
UML Class Diagram above, your MyArrayList class must have the following fields: - a private
field named capacity of type int, initialized to 8 - a private field named size of type int, initialized
to - a private field named storage of type object [ ], initialized to an object array of 8 elements
Structure of the Methods As described by the UML Class Diagram above, your MyArrayList
class must have the following methods: - a public method named addToEnd that takes an object
argument and returns nothing - a public method named insertAt that takes an int argument and an
object argument and returns nothing - a public method named removeAt that takes an int
arguments and returns nothing - a public method named getAt that takes an int argument and
returns an object - a public method named getsize that takes no arguments and returns an int - a
public method named makeCapacity that takes an int argument and returns noting - a public
method named trimExcess that takes no arguments and returns nothing Note that five of these
methods are declared in the MyList interface. You will be implementing these methods in this
MyArrayList concrete derived class. Also note that the getIterator method and the
MyArrayListiterator class are already implemented for you in the MyArrayList class. Make no
changes to this code. MyArraylist 1. This concrete class will store its elements in an array of
Object. The initial capacity of this array will be 8 elements. Since an array is a fixed size
structure, you may need to allocate a new array with increased capacity in order to accommodate
adding new elements. For this purpose you must implement the makeCapacity method. 2.
makeCapacity method - This method will take a minCapacity as an int argument. - If
minCapacity is less than current size or equal to the capacity, then this method should take no
action. - Otherwise the capacity of this MyArraylist must be changed to either 8 or minCapacity
(whichever is greater). - If capacity is to be changed, then this method will allocate a new array
of object sized to the new capacity - Then copy over all elements from the old array to the new
array - Then store the new array in the private storage variable for this instance 3. trimExcess
method - This method will remove any excess capacity by simply calling the makeCapacity
method with an argument value that is equal to the current size of this list. 4. addToEnd method -
Appends new item to end of list. For example: given the list { 1 , 2 , 3 } and an instruction to
addToEnd(99), the result would be this { 1 , 2 , 3 , 99 } . - If the current size is equal to the
current capacity, then this list is full to its current capacity, and capacity will need to be increased
before we can append the new element. To increase the capacity, call the makeCapacity method
with an argument. value that is twice the current capacity. - This method will add the new
element to the list at the next available index in the array storage. 5. insertAt method - Makes a
place at the specified index by moving all items at this index and beyond to the next larger index.
For example: given the list { 1 , 2 , 3 } and an instruction to insertAt ( 1 , 99 ) , the result would
be this { 1 , 99 , 2 , 3 } . - Throws a NoSuchElementException if the specified index is less than
or greater than size. - If the current size is equal to the current capacity, then this list is full to its
current capacity, and capacity will need to be increased before we can insert the new element. To
increase the capacity, call the makeCapacity method with an argument. value that is twice the
current capacity. 6. removeAt method - Removes the element at the specified index and moves
all elements beyond that index to the next lower index. For example: given the list { 1 , 2 , 3 }
and an instruction to removeAt (1), the result would be this { 1 , 3 } . - Throws a
NoSuchElementException if the specified index is less than 0 or greater than or equal to size. 7.
getAt method - Returns the item at the specified index. For example: given the list { 1 , 2 , 3 }
and an instruction to getAt (1), the return value would be 2 . - Throws a
NoSuchElementException if the specified index is less than or greater than or equal to size. 8.
getsize method - Returns the number of elements currently stored in the list.

More Related Content

Similar to Everything needs to be according to the instructions- thank you! SUPPO.pdf

For this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdfFor this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdffashiongallery1
 
(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manual(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manualChandrapriya Jayabal
 
4. The size of instructions can be fixed or variable. What are advant.pdf
4. The size of instructions can be fixed or variable. What are advant.pdf4. The size of instructions can be fixed or variable. What are advant.pdf
4. The size of instructions can be fixed or variable. What are advant.pdfmumnesh
 
Implementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfImplementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfmaheshkumar12354
 
Number 1 I have completed and number 6 is just uploading I .pdf
Number 1 I have completed and number 6 is just uploading I .pdfNumber 1 I have completed and number 6 is just uploading I .pdf
Number 1 I have completed and number 6 is just uploading I .pdfadvancethchnologies
 
This file contains a complete array-based MultiSet, but not the code.pdf
This file contains a complete array-based MultiSet, but not the code.pdfThis file contains a complete array-based MultiSet, but not the code.pdf
This file contains a complete array-based MultiSet, but not the code.pdfdeepaksatrker
 
Please add-modify the following to the original code using C# 1- Delet.docx
Please add-modify the following to the original code using C# 1- Delet.docxPlease add-modify the following to the original code using C# 1- Delet.docx
Please add-modify the following to the original code using C# 1- Delet.docxStewartt0kJohnstonh
 
this file has a complete array-based MultiSet, but not the code need.pdf
this file has a complete array-based MultiSet, but not the code need.pdfthis file has a complete array-based MultiSet, but not the code need.pdf
this file has a complete array-based MultiSet, but not the code need.pdfflashfashioncasualwe
 
Please help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfPlease help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfseoagam1
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfaromanets
 
Given the following errors and class in Java- How are these errors fix.pdf
Given the following errors and class in Java- How are these errors fix.pdfGiven the following errors and class in Java- How are these errors fix.pdf
Given the following errors and class in Java- How are these errors fix.pdfNicholasflqStewartl
 
Given the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docxGiven the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docxshericehewat
 
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 The MyLinkedList class used in Listing 24.6 is a one-way directional .docx The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
The MyLinkedList class used in Listing 24.6 is a one-way directional .docxKomlin1
 
Write a program that will test a name) method no sorting routine from.docx
 Write a program that will test a name) method no sorting routine from.docx Write a program that will test a name) method no sorting routine from.docx
Write a program that will test a name) method no sorting routine from.docxajoy21
 
01-intro_stacks.ppt
01-intro_stacks.ppt01-intro_stacks.ppt
01-intro_stacks.pptsoniya555961
 

Similar to Everything needs to be according to the instructions- thank you! SUPPO.pdf (20)

For this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdfFor this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdf
 
(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manual(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manual
 
4. The size of instructions can be fixed or variable. What are advant.pdf
4. The size of instructions can be fixed or variable. What are advant.pdf4. The size of instructions can be fixed or variable. What are advant.pdf
4. The size of instructions can be fixed or variable. What are advant.pdf
 
Implementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfImplementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdf
 
Number 1 I have completed and number 6 is just uploading I .pdf
Number 1 I have completed and number 6 is just uploading I .pdfNumber 1 I have completed and number 6 is just uploading I .pdf
Number 1 I have completed and number 6 is just uploading I .pdf
 
This file contains a complete array-based MultiSet, but not the code.pdf
This file contains a complete array-based MultiSet, but not the code.pdfThis file contains a complete array-based MultiSet, but not the code.pdf
This file contains a complete array-based MultiSet, but not the code.pdf
 
Please add-modify the following to the original code using C# 1- Delet.docx
Please add-modify the following to the original code using C# 1- Delet.docxPlease add-modify the following to the original code using C# 1- Delet.docx
Please add-modify the following to the original code using C# 1- Delet.docx
 
Computer programming 2 Lesson 13
Computer programming 2  Lesson 13Computer programming 2  Lesson 13
Computer programming 2 Lesson 13
 
this file has a complete array-based MultiSet, but not the code need.pdf
this file has a complete array-based MultiSet, but not the code need.pdfthis file has a complete array-based MultiSet, but not the code need.pdf
this file has a complete array-based MultiSet, but not the code need.pdf
 
chap12.ppt
chap12.pptchap12.ppt
chap12.ppt
 
Please help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfPlease help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdf
 
Basic data-structures-v.1.1
Basic data-structures-v.1.1Basic data-structures-v.1.1
Basic data-structures-v.1.1
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
 
Given the following errors and class in Java- How are these errors fix.pdf
Given the following errors and class in Java- How are these errors fix.pdfGiven the following errors and class in Java- How are these errors fix.pdf
Given the following errors and class in Java- How are these errors fix.pdf
 
Given the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docxGiven the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docx
 
Lec2
Lec2Lec2
Lec2
 
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 The MyLinkedList class used in Listing 24.6 is a one-way directional .docx The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 
Collections framework
Collections frameworkCollections framework
Collections framework
 
Write a program that will test a name) method no sorting routine from.docx
 Write a program that will test a name) method no sorting routine from.docx Write a program that will test a name) method no sorting routine from.docx
Write a program that will test a name) method no sorting routine from.docx
 
01-intro_stacks.ppt
01-intro_stacks.ppt01-intro_stacks.ppt
01-intro_stacks.ppt
 

More from firstchoiceajmer

Examine the screenshot provided below- Check only the answers that are.pdf
Examine the screenshot provided below- Check only the answers that are.pdfExamine the screenshot provided below- Check only the answers that are.pdf
Examine the screenshot provided below- Check only the answers that are.pdffirstchoiceajmer
 
example of- a- Reciprocal Interdependence b- Sequential interdependenc.pdf
example of- a- Reciprocal Interdependence b- Sequential interdependenc.pdfexample of- a- Reciprocal Interdependence b- Sequential interdependenc.pdf
example of- a- Reciprocal Interdependence b- Sequential interdependenc.pdffirstchoiceajmer
 
Example 2- Choose a business and classify the cost of this Business.pdf
Example 2-  Choose a business and classify the cost of this Business.pdfExample 2-  Choose a business and classify the cost of this Business.pdf
Example 2- Choose a business and classify the cost of this Business.pdffirstchoiceajmer
 
Examine the list of characters below for a hypothetical leaf and ident.pdf
Examine the list of characters below for a hypothetical leaf and ident.pdfExamine the list of characters below for a hypothetical leaf and ident.pdf
Examine the list of characters below for a hypothetical leaf and ident.pdffirstchoiceajmer
 
Examine seed dispersal mechanisms by completing the following paragrap.pdf
Examine seed dispersal mechanisms by completing the following paragrap.pdfExamine seed dispersal mechanisms by completing the following paragrap.pdf
Examine seed dispersal mechanisms by completing the following paragrap.pdffirstchoiceajmer
 
Ex- If this is the growth curve of E- coli growing in minimal medium w.pdf
Ex- If this is the growth curve of E- coli growing in minimal medium w.pdfEx- If this is the growth curve of E- coli growing in minimal medium w.pdf
Ex- If this is the growth curve of E- coli growing in minimal medium w.pdffirstchoiceajmer
 
Examine the Department of Justice- Include discussions about the organ.pdf
Examine the Department of Justice- Include discussions about the organ.pdfExamine the Department of Justice- Include discussions about the organ.pdf
Examine the Department of Justice- Include discussions about the organ.pdffirstchoiceajmer
 
EX2- Show that the Tanh function and the Sigmoid function are related.pdf
EX2- Show that the Tanh function and the Sigmoid function are related.pdfEX2- Show that the Tanh function and the Sigmoid function are related.pdf
EX2- Show that the Tanh function and the Sigmoid function are related.pdffirstchoiceajmer
 
Ex- There are two known potential defects on a certain brand of comput.pdf
Ex- There are two known potential defects on a certain brand of comput.pdfEx- There are two known potential defects on a certain brand of comput.pdf
Ex- There are two known potential defects on a certain brand of comput.pdffirstchoiceajmer
 
Evidence suggests that there may be _______ momentum and ________ reve.pdf
Evidence suggests that there may be _______ momentum and ________ reve.pdfEvidence suggests that there may be _______ momentum and ________ reve.pdf
Evidence suggests that there may be _______ momentum and ________ reve.pdffirstchoiceajmer
 
Every substance on earth consists of atoms- yet each substance has its.pdf
Every substance on earth consists of atoms- yet each substance has its.pdfEvery substance on earth consists of atoms- yet each substance has its.pdf
Every substance on earth consists of atoms- yet each substance has its.pdffirstchoiceajmer
 
Event participation details You are working as an Analyst in an event.pdf
Event participation details You are working as an Analyst in an event.pdfEvent participation details You are working as an Analyst in an event.pdf
Event participation details You are working as an Analyst in an event.pdffirstchoiceajmer
 
Evaluating WalMart from 2020-2022- Has total cash flow been increasing.pdf
Evaluating WalMart from 2020-2022- Has total cash flow been increasing.pdfEvaluating WalMart from 2020-2022- Has total cash flow been increasing.pdf
Evaluating WalMart from 2020-2022- Has total cash flow been increasing.pdffirstchoiceajmer
 
Evaluate the integral- Q2- (8 points) sinxcosx+2sinxcosxdx.pdf
Evaluate the integral- Q2- (8 points) sinxcosx+2sinxcosxdx.pdfEvaluate the integral- Q2- (8 points) sinxcosx+2sinxcosxdx.pdf
Evaluate the integral- Q2- (8 points) sinxcosx+2sinxcosxdx.pdffirstchoiceajmer
 
Evaluate the functions of regulatory elements (activators- repressors-.pdf
Evaluate the functions of regulatory elements (activators- repressors-.pdfEvaluate the functions of regulatory elements (activators- repressors-.pdf
Evaluate the functions of regulatory elements (activators- repressors-.pdffirstchoiceajmer
 
Eurrent Attempt in Progress Peete Company identifies the following ite.pdf
Eurrent Attempt in Progress Peete Company identifies the following ite.pdfEurrent Attempt in Progress Peete Company identifies the following ite.pdf
Eurrent Attempt in Progress Peete Company identifies the following ite.pdffirstchoiceajmer
 
Eukaryotic gene promoter (100bp) radio-labeled DNA + one of the protei.pdf
Eukaryotic gene promoter (100bp) radio-labeled DNA + one of the protei.pdfEukaryotic gene promoter (100bp) radio-labeled DNA + one of the protei.pdf
Eukaryotic gene promoter (100bp) radio-labeled DNA + one of the protei.pdffirstchoiceajmer
 
Eukaryoses regulate gene expression by malt ple mechanums- One inpedan.pdf
Eukaryoses regulate gene expression by malt ple mechanums- One inpedan.pdfEukaryoses regulate gene expression by malt ple mechanums- One inpedan.pdf
Eukaryoses regulate gene expression by malt ple mechanums- One inpedan.pdffirstchoiceajmer
 
Euro-British Pound- How would the call option premium change on the ri.pdf
Euro-British Pound- How would the call option premium change on the ri.pdfEuro-British Pound- How would the call option premium change on the ri.pdf
Euro-British Pound- How would the call option premium change on the ri.pdffirstchoiceajmer
 

More from firstchoiceajmer (20)

Examine the screenshot provided below- Check only the answers that are.pdf
Examine the screenshot provided below- Check only the answers that are.pdfExamine the screenshot provided below- Check only the answers that are.pdf
Examine the screenshot provided below- Check only the answers that are.pdf
 
example of- a- Reciprocal Interdependence b- Sequential interdependenc.pdf
example of- a- Reciprocal Interdependence b- Sequential interdependenc.pdfexample of- a- Reciprocal Interdependence b- Sequential interdependenc.pdf
example of- a- Reciprocal Interdependence b- Sequential interdependenc.pdf
 
Example 2- Choose a business and classify the cost of this Business.pdf
Example 2-  Choose a business and classify the cost of this Business.pdfExample 2-  Choose a business and classify the cost of this Business.pdf
Example 2- Choose a business and classify the cost of this Business.pdf
 
Examine the list of characters below for a hypothetical leaf and ident.pdf
Examine the list of characters below for a hypothetical leaf and ident.pdfExamine the list of characters below for a hypothetical leaf and ident.pdf
Examine the list of characters below for a hypothetical leaf and ident.pdf
 
Examine seed dispersal mechanisms by completing the following paragrap.pdf
Examine seed dispersal mechanisms by completing the following paragrap.pdfExamine seed dispersal mechanisms by completing the following paragrap.pdf
Examine seed dispersal mechanisms by completing the following paragrap.pdf
 
Ex- If this is the growth curve of E- coli growing in minimal medium w.pdf
Ex- If this is the growth curve of E- coli growing in minimal medium w.pdfEx- If this is the growth curve of E- coli growing in minimal medium w.pdf
Ex- If this is the growth curve of E- coli growing in minimal medium w.pdf
 
Examine the Department of Justice- Include discussions about the organ.pdf
Examine the Department of Justice- Include discussions about the organ.pdfExamine the Department of Justice- Include discussions about the organ.pdf
Examine the Department of Justice- Include discussions about the organ.pdf
 
EX2- Show that the Tanh function and the Sigmoid function are related.pdf
EX2- Show that the Tanh function and the Sigmoid function are related.pdfEX2- Show that the Tanh function and the Sigmoid function are related.pdf
EX2- Show that the Tanh function and the Sigmoid function are related.pdf
 
Ex- There are two known potential defects on a certain brand of comput.pdf
Ex- There are two known potential defects on a certain brand of comput.pdfEx- There are two known potential defects on a certain brand of comput.pdf
Ex- There are two known potential defects on a certain brand of comput.pdf
 
Evidence suggests that there may be _______ momentum and ________ reve.pdf
Evidence suggests that there may be _______ momentum and ________ reve.pdfEvidence suggests that there may be _______ momentum and ________ reve.pdf
Evidence suggests that there may be _______ momentum and ________ reve.pdf
 
Every substance on earth consists of atoms- yet each substance has its.pdf
Every substance on earth consists of atoms- yet each substance has its.pdfEvery substance on earth consists of atoms- yet each substance has its.pdf
Every substance on earth consists of atoms- yet each substance has its.pdf
 
Event participation details You are working as an Analyst in an event.pdf
Event participation details You are working as an Analyst in an event.pdfEvent participation details You are working as an Analyst in an event.pdf
Event participation details You are working as an Analyst in an event.pdf
 
Evaluating WalMart from 2020-2022- Has total cash flow been increasing.pdf
Evaluating WalMart from 2020-2022- Has total cash flow been increasing.pdfEvaluating WalMart from 2020-2022- Has total cash flow been increasing.pdf
Evaluating WalMart from 2020-2022- Has total cash flow been increasing.pdf
 
Evaluate the integral- Q2- (8 points) sinxcosx+2sinxcosxdx.pdf
Evaluate the integral- Q2- (8 points) sinxcosx+2sinxcosxdx.pdfEvaluate the integral- Q2- (8 points) sinxcosx+2sinxcosxdx.pdf
Evaluate the integral- Q2- (8 points) sinxcosx+2sinxcosxdx.pdf
 
Evaluate the functions of regulatory elements (activators- repressors-.pdf
Evaluate the functions of regulatory elements (activators- repressors-.pdfEvaluate the functions of regulatory elements (activators- repressors-.pdf
Evaluate the functions of regulatory elements (activators- repressors-.pdf
 
Evaluate k-22kk2+k.pdf
Evaluate k-22kk2+k.pdfEvaluate k-22kk2+k.pdf
Evaluate k-22kk2+k.pdf
 
Eurrent Attempt in Progress Peete Company identifies the following ite.pdf
Eurrent Attempt in Progress Peete Company identifies the following ite.pdfEurrent Attempt in Progress Peete Company identifies the following ite.pdf
Eurrent Attempt in Progress Peete Company identifies the following ite.pdf
 
Eukaryotic gene promoter (100bp) radio-labeled DNA + one of the protei.pdf
Eukaryotic gene promoter (100bp) radio-labeled DNA + one of the protei.pdfEukaryotic gene promoter (100bp) radio-labeled DNA + one of the protei.pdf
Eukaryotic gene promoter (100bp) radio-labeled DNA + one of the protei.pdf
 
Eukaryoses regulate gene expression by malt ple mechanums- One inpedan.pdf
Eukaryoses regulate gene expression by malt ple mechanums- One inpedan.pdfEukaryoses regulate gene expression by malt ple mechanums- One inpedan.pdf
Eukaryoses regulate gene expression by malt ple mechanums- One inpedan.pdf
 
Euro-British Pound- How would the call option premium change on the ri.pdf
Euro-British Pound- How would the call option premium change on the ri.pdfEuro-British Pound- How would the call option premium change on the ri.pdf
Euro-British Pound- How would the call option premium change on the ri.pdf
 

Recently uploaded

Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 

Recently uploaded (20)

Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 

Everything needs to be according to the instructions- thank you! SUPPO.pdf

  • 1. Everything needs to be according to the instructions, thank you! SUPPORTING CODE: MyList.java /** This interface specifies the basic operations of any list-like object. This interface contains a variation of the methods of the standard java.util.List interface. */ public interface MyList { /** Adds an element at the end of the list. */ public void addToEnd(Object o); /** Inserts an element at the specified index Throws NoSuchElementException if index is out of bounds. */ public void insertAt(int index, Object o); /** Removes the element at the specified index Throws NoSuchElementException if index is out of bounds. */ public void removeAt(int index); /** Returns the element at the specified index Throws NoSuchElementException if index is out of bounds. */ public Object getAt(int index); /** Returns the size of the list. @return the number of elements in the list */ public int getSize(); /** Returns a list iterator for this list. @return a list iterator for this list */
  • 2. public MyListIterator getIterator(); } MyListIterator.java /** A list iterator allows access of a position in a list. This interface contains a subset of the methods of the standard java.util.ListIterator interface. The methods for backward traversal are not included. */ public interface MyListIterator { /** Moves the iterator past the next element. @return the traversed element */ Object next(); /** Tests if there is an element after the iterator position. @return true if there is an element after the iterator position */ boolean hasNext(); } Main.java // you may use this file to write and run code to test your MyArrayList class public class Main { public static void main(String[] args) { } } FILE THAT NEEDS THAT NEEDS CODE: MyArrayList.java // Complete the implementation of your MyArrayList class in this file public class MyArrayList implements MyList {
  • 3. // Implement the required fields and methods here private int capacity = 8; private Object[ ] array = new Object [capacity]; private int size = 0; @Override public void add(Object o) { if (size >= capacity){ Object[] temp = new Object[2*array.length]; for(int i=0;i<size;++i){ temp[i] = array[i]; } this.capacity = 2*array.length; array = temp; array[size++] = o; return; } else { array[size++] = o; } } @Override public int size() {
  • 4. return size; } @Override public Object at(int index) { if (index >= capacity) return null; else return array[index]; } @Override public void insertAt(int index, Object o) { if (index >= capacity) return; else { size++; for (int x = size - 1; x > index; x--) { array[x] = array[x - 1]; } array[index] = o; } } @Override
  • 5. public void removeAt(int index) { if (index >= size || size == 0) return; else { Object e = array[index]; for (int x = index; x < this.array.length - 1; x++) { array[x] = array[x + 1]; } size--; } } public void ensureCapacity(int minCapacity) { } public void trimToSize() { ensureCapacity(size); } // Do not alter the code below @Override public MyListIterator getIterator() { return new MyArrayListIterator(); } private class MyArrayListIterator implements MyListIterator { int currentIndex = -1; @Override public Object next() { ++currentIndex; return storage[currentIndex]; }
  • 6. @Override public boolean hasNext() { return currentIndex < size - 1; } } } You are not allowed to use any of the standard Java collection types (like ArrayList) for this assignment. You may use simple arrays. Problem Description and Given Info For this assignment you are given the following Java source code files: - MyListiterator. java (This file is complete - make no changes to this file) - MyList. java (This file is complete - make no changes to this file) - MyArraylist.java (You must complete this file) - Main.java (You may use this file to write code to test your MyArrayList) You must complete the public class named MyArrayList with fields and methods as defined below. Your MyArrayList will implement the MyList interface that is provided in the myList. java file. Structure of the Fields As described by the UML Class Diagram above, your MyArrayList class must have the following fields: - a private field named capacity of type int, initialized to 8 - a private field named size of type int, initialized to - a private field named storage of type object [ ], initialized to an object array of 8 elements Structure of the Methods As described by the UML Class Diagram above, your MyArrayList class must have the following methods: - a public method named addToEnd that takes an object argument and returns nothing - a public method named insertAt that takes an int argument and an object argument and returns nothing - a public method named removeAt that takes an int arguments and returns nothing - a public method named getAt that takes an int argument and returns an object - a public method named getsize that takes no arguments and returns an int - a public method named makeCapacity that takes an int argument and returns noting - a public method named trimExcess that takes no arguments and returns nothing Note that five of these methods are declared in the MyList interface. You will be implementing these methods in this MyArrayList concrete derived class. Also note that the getIterator method and the MyArrayListiterator class are already implemented for you in the MyArrayList class. Make no changes to this code. MyArraylist 1. This concrete class will store its elements in an array of Object. The initial capacity of this array will be 8 elements. Since an array is a fixed size structure, you may need to allocate a new array with increased capacity in order to accommodate adding new elements. For this purpose you must implement the makeCapacity method. 2. makeCapacity method - This method will take a minCapacity as an int argument. - If minCapacity is less than current size or equal to the capacity, then this method should take no action. - Otherwise the capacity of this MyArraylist must be changed to either 8 or minCapacity (whichever is greater). - If capacity is to be changed, then this method will allocate a new array of object sized to the new capacity - Then copy over all elements from the old array to the new array - Then store the new array in the private storage variable for this instance 3. trimExcess method - This method will remove any excess capacity by simply calling the makeCapacity method with an argument value that is equal to the current size of this list. 4. addToEnd method - Appends new item to end of list. For example: given the list { 1 , 2 , 3 } and an instruction to addToEnd(99), the result would be this { 1 , 2 , 3 , 99 } . - If the current size is equal to the current capacity, then this list is full to its current capacity, and capacity will need to be increased before we can append the new element. To increase the capacity, call the makeCapacity method with an argument. value that is twice the current capacity. - This method will add the new
  • 7. element to the list at the next available index in the array storage. 5. insertAt method - Makes a place at the specified index by moving all items at this index and beyond to the next larger index. For example: given the list { 1 , 2 , 3 } and an instruction to insertAt ( 1 , 99 ) , the result would be this { 1 , 99 , 2 , 3 } . - Throws a NoSuchElementException if the specified index is less than or greater than size. - If the current size is equal to the current capacity, then this list is full to its current capacity, and capacity will need to be increased before we can insert the new element. To increase the capacity, call the makeCapacity method with an argument. value that is twice the current capacity. 6. removeAt method - Removes the element at the specified index and moves all elements beyond that index to the next lower index. For example: given the list { 1 , 2 , 3 } and an instruction to removeAt (1), the result would be this { 1 , 3 } . - Throws a NoSuchElementException if the specified index is less than 0 or greater than or equal to size. 7. getAt method - Returns the item at the specified index. For example: given the list { 1 , 2 , 3 } and an instruction to getAt (1), the return value would be 2 . - Throws a NoSuchElementException if the specified index is less than or greater than or equal to size. 8. getsize method - Returns the number of elements currently stored in the list.