Java代写:CMPS261 ListAPI

代写数据结构中的List,对提供的代码进行修改。

Instructions

  1. You are allowed to discuss the problem and solution design with others, but the code you submit must be your own. Your solution must include the certification of authenticity as given in the course syllabus.
  2. Follow the instruction on Moodle under Submitting to Moodle.

Problems

  1. Modify ListAPI.
    • a) Download ListAPI.zip from Moodle and extract the NetBeans project folder ListAPI from the archive file. In NetBeans under the Project tab, right click on ListAPI and select Rename. In the Rename Project dialog box, rename the project p4_1_your-clid, select the Also Rename Project Folder option and click Rename.
    • b) Define the following method in MyList and implement it in MyAbstractList.
    • c) Add code to TestMyArrayList.java to demonstrate that this method works correctly. Display the modified list using a java.util.Iterator[E] object and a while loop.
  2. Use ListAPI as a library.
    • a) Create a NetBeans project and name it p4_2_your-clid.
    • b) Create a JAR file of ListAPI.
      • i. Download ListAPI.zip from Moodle and extract the NetBeans project folder ListAPI from the archive file.
      • ii. In NetBeans, open ListAPI. Under the Project tab, right click on ListAPI and select Clean. Under the Project tab, right click on ListAPI and select Build. The created jar file is in dist folder.
      • iii. Move the JAR file to the folder that contains your project folder. Navigate to the ListAPI NetBeans project folder and open it. Open the folder dist. Copy the file ListAPI.jar and paste it in the same folder that contains the p4_2_your-clid project folder.
    • c) Attach the ListAPI.jar to your project.
      • i. Under the NetBeans Project tab, open the project created in step (a).
      • ii. Right click on Libraries and select Add JAR/Folder, and then navigate to ListAPI.jar. In the Add JAR/Folder dialog box, select ListAPI.jar, select Relative Path (which, if you have followed the preceding instructions, will be ../ListAPI.jar) and click OK.
      • iii. The classes in the JAR file are now available either by adding the following import statement to classes in your project.
    • d) In your project p4_2_your-clid, add code to enqueue 5 integer values in a listapi.GenericQueue, displaying the queue as each value is added. Then, dequeue each element in the queue, adding each value to a listapi.GenericStack, displaying the queue and stack as each value is moved from the stack to the queue. Finally, pop all values of the stack and add them to a listapi.MyArrayList, displaying the stack and the list as each value is moved from the stack to the list.
  3. Build and use your own minimal stack class using an array to hold the stack.
    • a) Create a NetBeans project and name it p4_3_your-clid.
    • b) In your project, create a stack class based on an array of type double of fixed size. In the class,
      • i. The array should have the default size of 5.
      • ii. The array size should be settable via a constructor.
      • iii. The following methods must be implemented:
        • A. push - inserts a value a the top of the stack
        • B. pop - returns the top value, removing it from the stack
        • C. isEmpty - returns true if the stack is empty, false otherwise
        • D. isFull - - returns true if the stack is full, false otherwise
    • c) Add code to your project demonstrating the stack and all methods and constructors in the class work correctly.
  4. Build and use your own minimal queue class using an array of type String of fixed size. to hold the queue.
    • a) Create a NetBeans project and name it p4_4_your-clid.
      • i. The array should have the default size of 5.
      • ii. The array size should be setable via a constructor.
      • iii. The following methods must be implemented:
        • A. enqueue - inserts a value at the rear of the queue
        • B. dequeue - returns the value at the front of the queue, removing the value from the queue
        • C. isEmpty - returns true if the queue is empty, false otherwise
        • D. isFull - - returns true if the queue is full, false otherwise
    • b) Add code to your project demonstrating the queue and all methods and constructors in the class work correctly.

Additional Requirements

  1. Identifiers must be descriptive, i.e. must self-document. The only exception granted is in the case of a for variable, that is a variable created as a simple counter as in the control variable in a for loop statement.

  2. Indention of all code blocks (compound statements, anything in braces), including single statements following selection or while statements, is required. NetBeans will do this fairly automatically as you type if your syntax is correct. In NetBeans, ALT-SHIFT-F will reformat a whole file if your syntax is correct.

  3. The main .java file [the one with the method public static void main(String[] args)] of your project must contain this minimal documentation.

]]>

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注