CS 175/286 - Homework 3

Improve my solution of homework 2 in two ways. (1) Read questions from the XML file quiz.xml (with a hardcoded URL, but I may change the contents for grading) (2) Give more feedback to the user. Specifically:

At the bottom of the first screen (with all questions), show a score field

In the first screen, show correctly answered questions in green, incorrectly answered questions in red, and unanswered questions in black

When a user selects a choice, use a toast to tell the user whether they did it right or not and return to the main activity.

You will need to send information back to the main activity. I updated the lecture notes for lesson 4 to show you how to do that.

In the response to that information, you need to repaint the list view. Use listView.invalidateViews().

Your solution should have a class Quiz and a class Question. Feel free to modify either or both classes (for example to keep track of correctly and incorrectly answered questions).

You check in a project that solves the assignment together with a report in a file report.txt. Use plain text, not Word or RTF, or you won't get credit for the report. Make sure that report.txt is in the hw03 directory inside your repo.

In the report, answer the questions given in the step-by-step instructions below.

  1. Make a new project with application and project name Homework03 in the package edu.sjsu.cs175.hw03.
  2. First write the code for reading the input. Explain in your report what challenges you faced with parsing the input. How did you decide what do do in startElement/endElement? Commit your code.
  3. Write an Eclipse JUnit 4 test edu.sjsu.cs175.hw03.QuizParserTest (not Android, not JUnit 3) that can be run outside Android to read the quiz and assert something about it. In your report, tell me what happens when you try to add this to your Android project. Then make a second project. Be sure to make it a Java project and not an Android project. Call the project Homework03Test and put the code in the directory hw03test of your cs175 repo, not the default inside the workspace. Then click Next and click on Projects. Click on Add. Select Homework03 and click on Ok. Click on Finish. In the Package Explorer, right-click on the project, select New → JUnit Test Case, make sure JUnit 4 is selected, set the package and class name and click Finish. Then fill in your test case and run it. Tell me in your report how you ran that test, and what happened when you did. Be sure to commit your code in the hw03test directory.
  4. Do not use any static variables. Transfer the question to the second activity, and a result back.
  5. When you transfer a result back to the MainActivity, it could be in the form of a boolean, an int, or a Question object. What did you choose and why?
  6. Answer both quiz questions in Lecture 6 and add them to your report.
  7. Commit again and push.
  8. Now clone your repo into /tmp, then build and run the program from the command line (not Eclipse).