/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/29 14:36:59*/ /*This class drives: */ package Police.core; import java.util.*; import java.sql.Time; import Police.*; import Police.json.*; public class Victim extends Person { //Class datatypes private String injurySuffered; //Class association variables private List crimeOccurrences; //Registry of our system. PoliceRegistry registry = PoliceRegistry.getInstance(); //Constructor public Victim(String aName, String aPhone, String aSex, String aAddress, String aAge, String aInjurySuffered) { super(aName, aPhone, aSex, aAddress, aAge); injurySuffered = aInjurySuffered; crimeOccurrences = new ArrayList(); registry.add(crimeOccurrences); } public boolean setInjurySuffered(String aInjurySuffered) { injurySuffered = aInjurySuffered; return true; } public String getInjurySuffered() { return injurySuffered; } public List getCrimeOccurrences() { return crimeOccurrences; } public CrimeOccurrence addCrimeOccurrence(String aLocation, String aDate, String aTime, String aDescription) { CrimeOccurrence newCrimeOccurrence; newCrimeOccurrence = new CrimeOccurrence(aLocation, aDate, aTime, aDescription); if (!crimeOccurrences.contains(newCrimeOccurrence)) { registry.add(newCrimeOccurrence); crimeOccurrences.add(newCrimeOccurrence); } return newCrimeOccurrence; } public CrimeOccurrence addCrimeOccurrence(CrimeOccurrence aCrimeOccurrence) { if (!crimeOccurrences.contains(aCrimeOccurrence)) crimeOccurrences.add(aCrimeOccurrence); return aCrimeOccurrence; } public void delete() { } public void deleteCrimeOccurrence(CrimeOccurrence aCrimeOccurrence) { if (crimeOccurrences.contains(aCrimeOccurrence)) { crimeOccurrences.remove(aCrimeOccurrence); //registry.removeObj(registry.getKey(aCrimeOccurrence)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { return true; } /*********************************** * Returns the attribute list along with the * class ID in JSON format. ***********************************/ public JSONObject getAttributes() throws JSONException { JSONObject obj = new JSONObject(); obj.put("CLASS_ID", registry.getKey(this)); obj.put("injurySuffered", getInjurySuffered()); return obj; } }