Assignment|代做Java – MyArrayList

Assignment|代做Java – 这是一个基础的java练习题目,通过java进行arraylist方面的训练

CSCI 225 assignment 1 1

MyArrayList

Due: Sunday, Sept. 23, 2018, 10PM.

The java ArrayList is a resizable-array implementation of the Java List interface. The ArrayList has a capacity which can grow automatically as elements are added. For details of the standard ArrayList behaviour, please see http://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html.

In this assignment, you will implement your own MyArrayList class, which imitates a subset of the ArrayList functionality. Whenever the capacity of your array changes as a result of a method call, you must make a deep copy of the array contents to a new array. For details explaining the required behaviour of each function, please refer to the comments written above each method prototype in the supplied skeleton MyArrayList.java file.

Download MyArrayList.java and CSCI225A1SimpleDriver.java from C4.

Include your name in the comments at the top of your MyArrayList.java file. Complete the implementation of the methods in MyArrayList.java that contain the comment //to be completed.

Use CSCI225A1SimpleDriver.java to test your code. It is highly recommended to add your own test methods to CSCI225A1SimpleDriver.java, so that you can thoroughly test both general and special cases for each method (e.g. add/remove/retrieve from an empty list, from a full list, partially full list, from the front/back/middle of the array, from invalid indices, etc.)

Note

Method stubs

If you are unable to complete the implementation of any method, you may write a stub method. A stub contains in its method body only a default return statement of the appropriate type, so that the file is able to compile without errors.

Here is an example of a stub for the method public int removeAt(int index), which must return an int in order to compile:

public int removeAt(int index) { return – 1; }

Deliverables

Please upload to C4 before the deadline:

  • Your MyArrayList.java file with all methods completed, without syntax errors.

发表评论

电子邮件地址不会被公开。 必填项已用*标注