### Question:
Scores implements PlayerScores { @Override public void update(Object data) { if (data instanceof String) { try { data = new JSONObject((String)data); } catch (Exception e) { try { data = Integer.valueOf((String)data); } catch (Exception e2) { } } } if (data instanceof Integer) { score = Integer.valueOf(data.toString()); log.put(SCORE, score); } else if (data instanceof JSONObject) { JSONObject json = (JSONObject) data; score = Integer.valueOf(json.getInt(SCORE)); log.put(SCORE, score); log.put(ROUNDS, json.getJSONArray(ROUNDS)); } else { } } Scores(Object startScore); @Override int clear(); @Override void update(Object data); @Override JSONObject getScore(); @Override void event(Object input); final static String SCORE; static final String ROUNDS; }### Answer:
@Test public void testUpdate() { scores = new Scores("{'score':0}"); scores.update(new Object()); assertScore(0); scores.update("1"); assertScore(1); scores.update(2); assertScore(2); scores.update("{\"score\":3,\"rounds\":[0]}"); assertScore(3); assertRounds("[0]"); scores.update(new JSONObject("{\"score\":4,\"rounds\":[1,2]}")); assertScore(4); assertRounds("[1,2]"); }