The method: handleRequest is called when I enter add-message?s=
What are the relevant arguments to those methods, and the values of any relevant fields of the class?
The relevant arguments to this method are:
-
URI url: this is the URI that is received by the java program
-
Num: this is the current index of the String array wordBank. This value is used to add an element to the String[] wordBank
-
String[] wordBank: this is the string array that stores all the user’s input
How do the values of any relevant fields of the class change from this specific request? If no values got changed, explain why.
-
Num: with each input, the num variable increases by 1 in order to match the index
-
String[] wordBank: this value changes by appending a new string input element into the array.
(above image is adding the word "hello" to the word bank)
(above image is adding the word "hello world" to the word bank and showing the history of all the words added)
(above image is showing the code behind the web app)
reverseInPlace: Fixed by using a temporary int variable n
Failure Inducing Input: int input2 = { 1,2,3,4,5}
Expected output: {5,4,3,2,1}
Actual output: {0,0,0,0,0,0,0,0}
The reversed method fails to initialize the indices to the values of the original array in the new array. Instead all the values are zeros. If we want the code to work as expected we should make newArray a copy of arr, then we can leave the rest of the code as is.
Now, all tests is passed:
I learned that coding bugs can often be caused by small syntax errors or incorrect logic and it is important to carefully review and test code before deployment. Also, Github is a useful tool for collaborating with others on code projects and tracking changes through version control. In addition, I also learned the difference between bugs and symptoms.
Here are some github commands I learned:
git clone [repository url]: downloads a repository from a remote source to local machine.
git init: initializes an empty Git repository in the current directory.
git add [file name]: stages a file for commit.
git commit -m "[commit message]": creates a commit with a message.
git push: pushes local commits to the remote repository.
git pull: fetches and merges the latest changes from a rem