Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are a whole lot of things wrong with your code, but coding to your functionality and disregarding the proper <a href="http://www.oracle.com/technetwork/java/codeconventions-150003.pdf" rel="nofollow">java coding conventions</a> (which you clearly ignore for some reason and which I'm not going to fix). I came up with this. 1 method to find your patient in your list, and 1 method to calculate the patient total from the 2 lists.</p> <pre><code>public patient_class findPatient(List&lt;patient_class&gt; patients, String search) { for(patient_class patient: patients) //used enhanced for loop if(patient.getid().equals(search)) { return patient; } } return null; // no patient found matching the search id } public int calculatePatientTotal(List&lt;patient_class&gt; patientsList1, List&lt;patient_class&gt; patientsList2, String search){ patient_class patientInList1 = findPatient(patientsList1,search);// assuming unique id patient_class patientInList2 = findPatient(patientsList2,search);// assuming unique id int total=0; // calc general total if(patientInList1!=null{ // I'm assuming you put these getters in methods instead of public properties! // hence the brackets at the end total= patientInList1.gettotaltestcost() + patientInList1.gettotaltreatmentcost(); } // add any extra charges if(patientInList2!=null ){ // I'm assuming this is the method that calculates the other charges in that patient object. total+= patientInList2.getOtherCharges(); } return total; } </code></pre> <p>Next time I would recommend you think about the proper structures to use and mainly to not scatter same info over different items.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload