In your Git workspace, make a directory midterm in which you place the answers. Unzip this file into that directory, so that you have directories midterm/problem1 etc.

Make four pushes, after you answer each question.

Each question should take you at most 15 minutes. If it takes more, move on to the next.

You need not compile your code, but you can if you like.

You can consult the internet, files on your laptop, books, and notes. But of course you may not make contact with anyone during the exam. No email, chat, etc.

Question 1. Modify my solution to homework 1 so that you use a group of radio buttons instead of the four regular buttons. I don't assume that you know anything about radio buttons. Just read the documentation and use your general knowledge about Android UI components and events to transform the code. Submit all Java and XML files that you are changing. At the outset, the first button should be checked. Note: When you click on a button, nothing should happen.

15 points

10 bonus points if clicking on the buttons shows a toast specifying which button has been clicked. (Hint: Attach the listener to the radio group.)

Question 2. In my solution for homework 5, I had to work hard to associate the films with empty currentShowings (i.e. the shorts) with their ProgramItem. Since then, the data feed has been updated. Now a Show with short films has one or more ShortId custom properties. Each of them is the ID of a short film.

In the old solution, short films were put into a map, with the (guessed) title of their parent as key. All shorts with the same guessed title were collected in a set, and that set was later added to the parent film.

Now we no longer want to guess keys. Instead, put shorts into a HashMap<Integer, Film>, mapping from their ID to the film.

In the second loop, instead of adding the shorts by title, use the new data. Check if the show has a ShortId set in show.customProperties. If so, for each ID in that set, add the short film. Since you stored it away previously in a map, you can now retrieve it by ID.

Also, somewhere you need to add the short films to the festival's films.

15 points

For a bonus, run the unit test. Note that two unit tests fail. That is unfortunately a consequence of bad data. Films 7026, 7060, and 7067 start with "Shorts Program" instead of "Part of Shorts Program". Adjust the test cases so that they properly reflect the shorts in program items 7117 and 7121. (10 bonus points)

Question 3. Modify my solution for homework 6. I changed the JSON file so that it has optional titles for problems with lengthy text. Show these in the initial list of problems as well as in the header of each problem. You need to move the problem text into the content area. If a problem has no title, show the problem text in the list of problems, and show a blank header when viewing the problem.

15 points

Question 4. Homework 7 asked you to implement a Question class in Objective-C. In this problem, you should also implement that class, but the details are likely to be different from your solution. You should write the Objective C equivalent of this Java class:

public class Question {
    private String text;
    private ArrayList<String> choices;
    private int correctChoice;

     public Question() { choices = new ArrayList<String>(); }
  
    public void addChoice(String choice, boolean isCorrect) {
    	if (isCorrect) correctChoice = choices.size();
    	choices.add(choice);    	
    }

     public boolean isCorrect(int response) { return response == correctChoice; } 
    public String> choiceAt(int choice) { return choices.get(choice); }
  
    public String getText() { return text; }
    public void setText(String text) { this.text = text; }  
}

Use a property for text but not for choices or correctChoice. Supply a file Question.h and Question.m. Hint: Use a NSMutableArray.

25 points