ICTPRG414 Part 1: Practical tasks
Task 1: Write code
1. Declare an array to store the five athletes’ name.
2. Declare an array to store the five athletes’ height in cm.
3. Define a function with two parameters (name and height) to store an athlete’s information into the arrays.
a. In the function, create insertion algorithms to operate on the arrays and store the information in sequential order. For example, the first and the second names entered will be stored in the first and second position of the first array.
b. The function will return either ‘array is full’ or ‘added successfully’.
4. Define a function with one parameter (position) to find an athlete by the position stored in the array and to return the details of athlete found.
a. In the function, code random access algorithms to operate on the arrays and return the athlete’s information as a string.
5. Define a function with one parameter (name) to remove an athlete’s information from the arrays.
a. In the function, create deletion algorithms to operate on the arrays and remove the athlete information found in the two arrays.
b. The function will return either ‘not found’ or ‘removed successfully’.
6. Save the script file as TaskOne.js.
7. Save copies of TaskOne.js as TaskTwo.js and TaskThree.js.
Task 2: Maintain and test code
Refactoring is required to make the code easier to maintain.
1. Modify the function in TaskTwo.js to remove an athlete by splitting the function into two smaller functions:
a. The first function must find the position of an athlete in the name array. This function has one parameter (name) to find an athlete by the name and to return the position of athlete found in the array, using a sequential access algorithm. If the information cannot be not found, return -1.
b. The second function must remove an athlete’s information from the arrays. This function has one parameter (name) and uses the preceding function to find the position of an athlete in the arrays. Once the position is found, use deletion algorithms to remove the information from both arrays. The function will return either ‘not found’ or ‘removed successfully’.
c. Save the updated TaskTwo.js script file.
2. Design and create a test plan in a word-processed document to ensure your code works correctly. Your test plan should include correct and incorrect data and actions, as well as the expected outcomes. Refer to the program specifications to ensure your code meets the requirements.
3. Follow your test plan to test your code using a suitable testing tool. Record the test results in the test plan, including the actual outcomes and screenshots or log files of the test.
Task 3: Update code
Modify the TaskThree.js script and the provided web page file TaskThree.html according to the following requirements:
1. TaskThree.html includes two HTML button elements. Update the required event attributes of the buttons so that Save and Find operations will be performed when a user clicks the relevant buttons.
2. Link the TaskThree.js file to the TaskThree web page.
3. Update the TaskThree.js file as follows:
a. Remove the two functions:
Find an athlete by position
Remove an athlete.
b. Define a data structure to store each athlete’s information.
c. Replace the two arrays with one array. Use the data structure to describe the information stored in the array.
d. Change the function to store an athlete’s information into the array:
Replace the two parameters (name and height) with one parameter. Use the data structure to describe the parameter data.
Modify the insertion algorithms to ensure that the new information is stored successfully in the array.
e. Change the function to find an athlete by name:
Replace the sequential access algorithm to operate on the arrays with a binary search algorithm. To implement this, the array’s data must be sorted. You may refer to an online example available at Array.prototype.sort() to learn about sorting data in arrays.
Task 4: Debug code
Debug the changes implemented in Task 3 using a suitable tool provided by an integrated development environment (IDE), such as Chrome DevTools. Create a word-processed document containing the following:
2. Outline the errors found during debugging.
3. Correct the errors that you have found and save your files.
Task 5: Produce documentation
本网站支持淘宝 支付宝 微信支付 paypal等等交易。如果不放心可以用淘宝交易！
E-mail: [email protected] 微信:itcsdx