Adding a Suspect to the Model Layer

Next, return to Crime.java and add a new JSON constant and a member variable to give Crime a field that will hold the name of a suspect. Also, modify the JSON methods to serialize the suspect into and out of JSON code and add new accessor methods.

Listing 21.2  Adding suspect field (Crime.java)

p​u​b​l​i​c​ ​c​l​a​s​s​ ​C​r​i​m​e​ ​{​
 ​ ​ ​ ​.​.​.​
 ​ ​ ​ ​p​r​i​v​a​t​e​ ​s​t​a​t​i​c​ ​f​i​n​a​l​ ​S​t​r​i​n​g​ ​J​S​O​N​_​P​H​O​T​O​ ​=​ ​"​p​h​o​t​o​"​;​
 ​ ​ ​ ​p​r​i​v​a​t​e​ ​s​t​a​t​i​c​ ​f​i​n​a​l​ ​S​t​r​i​n​g​ ​J​S​O​N​_​S​U​S​P​E​C​T​ ​=​ ​"​s​u​s​p​e​c​t​"​;​

 ​ ​ ​ ​.​.​.​
 ​ ​ ​ ​p​r​i​v​a​t​e​ ​P​h​o​t​o​ ​m​P​h​o​t​o​;​
 ​ ​ ​ ​p​r​i​v​a​t​e​ ​S​t​r​i​n​g​ ​m​S​u​s​p​e​c​t​;​ ​ ​ ​ ​p​u​b​l​i​c​ ​C​r​i​m​e​(​J​S​O​N​O​b​j​e​c​t​ ...

Get Android Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.