5.6 Quiz App Projects Curriculum Page
Portfolio Reflection Questions:
1. Describe your solution for the second project that added a Search button. Provide a screenshot of the search button click code that uses a complex algorithm with loops and lists. Why was a loop necessary?
- Screenshot attached below.
- In order to create the second enhancement that was adding a search button, I started by adding a text box to the UI and a button that would be for the user to search what they typed (what they search must be in the actual questions in order for a question to pop up). As for the blocks, I used a for each loop block that starts at 1 and goes in increments of 1 until it reaches the max which is the length of the lists. Then I added an if else block which causes the question to pop up only if the user typed into the text box a word that is in one of the questions. If it does match, it will display the corresponding question and image. Due to the for each loop block, every question in the list will be gone over to search for the piece of text that the user types in until a match is found. If a match isn't found, nothing happens.
2. Write AP text-style pseudocode for a linear search that searches through a list to find an item x. It should display found if the x is equal to an item in the list.
- Repeat list length of list times
Check each value for x
If value=x, display found
3. Give brief descriptions of the enhancements you added to your app for the third project, a quiz topic of your own choosing. Provide screenshots of important blocks and describe how you used them to solve certain programming problems.
- Screenshot attached below.
- For my enhancement #3, I changed the app so that it is tennis themed. I changed all the questions, images, and pictures. I kept all of the important blocks from my previous version, however I added an enhancement that involves a timer. If the user doesn't answer the question in 15 seconds, they will lose a point. In the blocks, they check to see when the available time ends at 0, and when it does it adds to the wrong answer which causes it to move to the next question.
4. To practice for the Create project prompt, grab a screenshot of a program code segment from your project that implements an algorithm that includes two or more algorithms within it and includes mathematical and/or logical concepts. An ideal algorithm is a procedure that you created that includes calls to other procedures that you created, where at least one of those includes math or logic (ifs or loops). Describe how each of the two algorithms within the bigger algorithm functions independently as well as in combination to form a new algorithm.
- Screenshot attached below.
- Both of the algorithms works together in order to create one large algorithm that controls the maintenance of the score and its display on the UI if the user enters the answer correctly. Individually, the first block of code attached below functions by comparing the correct answer that is saved in the code with the answer that the user enters. Then, if it is correct the label will change to alert the user that it is in fact correct and it will call the score procedure. If it is incorrect, the label will change to notify the user and the correct answer will be shown on the screen. As for the second algorithm which is the "score" procedure, its main purpose is to change the score count on the screen based on the guesses made by the user. So, if it is correct, the score will change to be the global score value + 1 and the score label will change accordingly. If the answer isn't correct, the score will stay the same.