I have an assignment to implemented a Quarantine project where I was left with the some unit tests and a skeleton of the implementation. I provided the solution below and get rejected from the interview. The feedbacks I get (I feel lucky that they provided, usually, they have legal issues) are, NO indicator of design (DDD, or design patterns) The code is not scalable (extendable)Overall, this is C code written in Java (bit harsh and made me sad). Is there any better way to do that? I mainly looking suggestions from the very experienced engineers. public class QuarantineTest {    private Quarantine quarantine;    @Before    public void setUp() {        // The responsibility of the Quarantine object is to simulate diseases on a group of patients.        // It is initialized with a list of patients' health status, separated by a comma.        // Each health status is described by one or more characters        // (in the test below, we will always have only one disease / patient)        // The characters mean:        // H : Healthy        // F : Fever        // D : Diabetes        // T : Tuberculosis        quarantine = new Quarantine(F,H,D,D,D,H,T);        // Quarantine provides medicines to the patients, but can not target a specific group of patient.        // The same medicines are always given to all the patients.        // Then Quarantine can provide a report with this format:        // F:1 H:2 D:0 T:1 X:3        // Report give the number of patients that have the given disease.        // X means Dead    }    @Test    public void beforeTreatment() throws Exception {        assertEquals(F:1 H:2 D:3 T:1 X:0, quarantine.report());    }    // people died in the Diabetes    @Test    public void noTreatment() throws Exception {        quarantine.wait40Days();        // diabetics die without insulin        assertEquals(F:1 H:2 D:0 T:1 X:3, quarantine.report());    }    // feaver is cured    //  people died in the Diabetes    @Test    public void aspirin() throws Exception {        quarantine.aspirin();        quarantine.wait40Days();        // aspirin cure Fever        assertEquals(F:0 H:3 D:0 T:1 X:3, quarantine.report());    }    @Test    public void antibiotic() throws Exception {        quarantine.antibiotic();        quarantine.wait40Days();        // antibiotic cure Tuberculosis        // but healthy people catch Fever if mixed with insulin.        assertEquals(F:1 H:3 D:0 T:0 X:3, quarantine.report());    }    @Test    public void insulin() throws Exception {        quarantine.insulin();        quarantine.wait40Days();        // insulin prevent diabetic subject from dying, does not cure Diabetes,        assertEquals(F:1 H:2 D:3 T:1 X:0, quarantine.report());    }    @Test    public void antibioticPlusInsulin() throws Exception {        quarantine.antibiotic();        quarantine.insulin();        quarantine.wait40Days();        // if insulin is mixed with antibiotic, healthy people catch Fever        assertEquals(F:3 H:1 D:3 T:0 X:0, quarantine.report());    }    @Test    public void paracetamol() throws Exception {        quarantine.paracetamol();        quarantine.wait40Days();        // paracetamol heals fever        assertEquals(F:0 H:3 D:0 T:1 X:3, quarantine.report());    }    @Test    public void paracetamolAndAspirin() throws Exception {        quarantine.paracetamol();        quarantine.aspirin();        quarantine.wait40Days();        // paracetamol kills subject if mixed with aspirin        assertEquals(F:0 H:0 D:0 T:0 X:7, quarantine.report());    }}import java.util.LinkedHashMap;import java.util.Map;import java.util.regex.Pattern;import java.util.stream.Collectors;public class Quarantine {    private Map<Character, Integer> map;    boolean insuline;    boolean wait40Days;    boolean antibiotic;    boolean aspirin;    boolean paracetamol;    public Quarantine(String subjects) {        try {            map = Pattern.compile(,)                    .splitAsStream(subjects)                    .collect(Collectors.groupingBy(                            s -> s.charAt(0),                            LinkedHashMap::new,                            Collectors.collectingAndThen(Collectors.counting(), Long::intValue)                    ));            map.put('X', 0);        } catch (Exception e) {            e.printStackTrace();        }    }    // aspirin cures fever    public void aspirin() {        aspirin = true;    }    public void antibiotic() {        antibiotic = true;    }    public void insulin() {        insuline = true;    }    public void paracetamol() {        paracetamol = true;    }    public void wait40Days() {        if (antibiotic) {            // antobiotic is mixed with the insuline            if (insuline) {                map.put('F', map.get('F') + map.get('H'));                map.put('H', map.get('T'));                map.put('T', 0);                return;            }            // only the antibiotic            else {                map.put('H', map.get('H') + map.get('T'));                map.put('T', 0);                wait40Days = true;            }        } else if (paracetamol) {            // paracetamol mixed with the aspirin kills everyone            if (aspirin) {                map.put('X', map.get('X') + map.get('F') + map.get('H') + map.get('D') + map.get('T'));                map.put('F', 0);                map.put('H', 0);                map.put('D', 0);                map.put('T', 0);                return;            } else { // only provides the paracetamol as medication                map.put('H', map.get('H') + map.get('F'));                map.put('F', 0);                wait40Days = true;            }        } else if(aspirin) { // only provides aspirin as medication            map.put('H', map.get('H') + map.get('F'));            map.put('F', 0);            wait40Days = true;        } else if (insuline) {            // only provision of insuline prevents death from the diabetes            return;        } else {         // no medicine was provided, just waited for the 40 days            wait40Days = true;        }        /*        check if we will needs to wait for 40 days        after the medication to see the affect        * */        if (wait40Days) {            map.put('X', map.get('D'));            map.put('D', 0);            wait40Days = false;        }    }    // get the Quarantine report    public String report() {        try {            final String[] result = {};            map.forEach((k, v) -> result[0] += k.toString() + : + v.toString() +  );            return result[0].trim();        } catch (Exception e) {            e.printStackTrace();        }        return null;    }}
Quarantine implementation
java;object oriented;design patterns;junit
So yes, your code lack of Object Oriented design and patterns. A quick look give me the idea that the Quarantine can be a factory for Medicine, but that is a little improvement.The first thing to do is to create your models. You have the Quarantine class but also a group of Patients, some Medecine and a set of Disease.The Disease are a facts, something that you will just accept, so it can be an enumeration. [pattern enumeration]The Patients maintains a counter, that can move from one group to the other. It just maintains an integer an can be seen as a decorator. [pattern decorator]class Patients {   int size;   void becomes(Patients other) {     other.size += this.size;     this.size = 0;   }}The Quarantine distribute one or more Medicine to all the Patients, I have created a Treatment class to maintains all the Medicine. This class is immutable and allows me to query it and add or remove Medicine. The quarantine can be a factory and a builder (because it compose the treatment). The new Treatment class can be seen as many patterns, helper or state]. But also a composite because it implements the Medicine but is also a delegate.Finally, the biggest part is from the Medicine where all the logic reside. When add to the Treatment a Medicine will change the results of it. So a Medicine must be combined with an existing Treatment and given to a group of Patients to produce his effects. The strategy pattern apply to this class.interface Medicine {  void on(Quarantine quarantine);  Treatment combine(Treatment treatment);}