Rtrix Posted October 22, 2014 Report Posted October 22, 2014 (edited) 1. Change the implementation of the Population class so that it uses an ArrayListinstead of an array for the population as follows. N.B. You should only have to changePopulation.java – the rest of the program should continue to work exactly the same.(a) Change the declaration of the field and add code to the constructor to create theArrayList.( Change any methods which use the population so they work with the ArrayList ratherthan an array.2. (a) Add a new field deathRate to the Population class that gives the probability ofdying from the infection. Assign this a value of 0.0 in the constructor. Now add asecond constructor which initialises deathRate as a parameter as well as all the otherfields. Document using the javadoc format.( Write “get” and “set” methods for deathRate. Document using the javadoc format.3. Change the update method in Population so that infected people die withprobability given by deathRate. Remove them from the population when this happens.HINT: this is tricky to get right – I suggest creating an ArrayList to record which peopledie in one iteration. Then go through that ArrayList removing them from the population.(am facut ceva, da' imi da eroare nu inteleg de ce, si vreau sa vad cum e exact)Fisierele: https://www.dropbox.com/sh/ybxy4hpxegrtix1/AABLKJZE7Deur-Bxv2_AzbG7a?dl=0 Edited October 22, 2014 by Rtrix Quote
Ganav Posted October 22, 2014 Report Posted October 22, 2014 URL-ul nu este valid. Te rog posteaza codul folosind etichetele code.Un exemplu de ArrayList este urmatorul:List<String> lista = new ArrayList<String>(); list.add("RST"); list.add("forums");Practic poti sa faci ArrayList-ul de orice tip. Gasesti aici mai multe detalii:Trail: Collections (The Java™ Tutorials)ArrayList (Java Platform SE 6)List (Java Platform SE 6) Quote
Rtrix Posted October 23, 2014 Author Report Posted October 23, 2014 3. Change the update method in Population so that infected people die withprobability given by deathRate. Remove them from the population when this happens.HINT: this is tricky to get right – I suggest creating an ArrayList to record which peopledie in one iteration. Then go through that ArrayList removing them from the population.https://www.dropbox.com/sh/ybxy4hpxegrtix1/AABLKJZE7Deur-Bxv2_AzbG7a?dl=0Mai am asta. Quote