Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8896225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:59:06+00:00 2026-06-14T23:59:06+00:00

This is the tester class, the terminal window only displays from the line System.out.println

  • 0

This is the tester class, the terminal window only displays from the line

System.out.println ("Waiting position for patient3: " + daylog.findWaitingPosition (patient3));

Which I mention out in the code below (scroll it down a bit to see my text) . It does not display anything above it, anyone know why?

import java.text.DecimalFormat;

public class DayLogTest
{
public static void main (String[] args)
{
    DayLog today = new DayLog (11,12,1992);

    doTest(today);
}

private static void doTest (DayLog daylog)
{
    Patient patient1 = new Patient(1111, "aaaa", "aaaa", 11,11,1991);
    Patient patient2 = new Patient(2222, "bbbb", "bbbb", 9,12,1992);
    Patient patient3 = new Patient(3333, "cccc", "cccc", 8,7,1941);
    Patient patient4 = new Patient(4444, "dddd", "dddd", 4,5,1851);
    Patient patient5 = new Patient(5555, "eeee", "eeee", 1,1,1231);

    System.out.println ("Test 1");
    System.out.println ("------------------------------------------------------------");
    System.out.println ("Phase 1: Adding Patients (patient1, patient2, patient3) ");
    daylog.addPatient (patient1, 12,30);
    daylog.addPatient (patient2, 12,40);
    daylog.addPatient (patient3, 8,40);
    System.out.println ("Number of Patients Arrived: " + daylog.getArrived());
    System.out.println ("Number of Patients Waiting: " + daylog.getNumberWaiting());
    System.out.println ("Waiting position for patient1: " + daylog.findWaitingPosition (patient1));
    System.out.println ("Waiting position for patient2: " + daylog.findWaitingPosition (patient2));
    System.out.println ("Waiting position for patient3: " + daylog.findWaitingPosition (patient3));
    System.out.println ("------------------------------------------------------------");
    System.out.println ("Treating patient1");
    daylog.treatPatient (patient1, 15, 30);
    System.out.println ("Number of Patients Waiting: " + daylog.getNumberWaiting());
    System.out.println ("Waiting position for patient2: " + daylog.findWaitingPosition (patient2));

DOES NOT PRINT ANYTHING ABOVE HERE IN TERMINAL WINDOW
DOES NOT PRINT ANYTHING ABOVE HERE IN TERMINAL WINDOW
DOES NOT PRINT ANYTHING ABOVE HERE IN TERMINAL WINDOW


    System.out.println ("Waiting position for patient3: " + daylog.findWaitingPosition (patient3));
    System.out.println ("------------------------------------------------------------");
    System.out.println ("Phase 2: Adding patient4 and patient 5");
    daylog.addPatient (patient4, 5,25);
    daylog.addPatient (patient5, 16,24);
    System.out.println ("Number of Patients Arrived: " + daylog.getArrived());
    System.out.println ("Number of Patients Waiting: " + daylog.getNumberWaiting());
    System.out.println ("Waiting position for patient2: " + daylog.findWaitingPosition (patient2));
    System.out.println ("Waiting position for patient3: " + daylog.findWaitingPosition (patient3));
    System.out.println ("Waiting position for patient4: " + daylog.findWaitingPosition (patient4));
    System.out.println ("Waiting position for patient5: " + daylog.findWaitingPosition (patient5));
    System.out.println ("------------------------------------------------------------");
    System.out.println ("Treating patient 3 and 5");
    daylog.treatPatient (patient3, 11,40);
    daylog.treatPatient (patient5, 19,24);
    System.out.println ("Number of Patients Arrived: " + daylog.getArrived());
    System.out.println ("Number of Patients Waiting: " + daylog.getNumberWaiting());
    System.out.println ("Waiting position for patient2: " + daylog.findWaitingPosition (patient2));
    System.out.println ("Waiting position for patient4: " + daylog.findWaitingPosition (patient4));
    System.out.println ("------------------------------------------------------------");
    System.out.println ("Phase 3: printReport method");
    daylog.printReport();
    System.out.println ("------------------------------------------------------------");
    System.out.println ("Phase 4: printWaitingList Method");
    daylog.printWaitingList();
    System.out.println ("------------------------------------------------------------");
    System.out.println ("Phase 5: getAverageWaitingTime Method");
    System.out.println ("I have designed the test to be 3 hours average so far, which is 180 minutes");
    DecimalFormat fmt = new DecimalFormat ("");
    System.out.println ("Average waiting time: " + fmt.format(daylog.getAverageWaitingTime()) + " minutes");
    System.out.println ("------------------------------------------------------------");
    System.out.println ("Phase 6: Adding patient2");
    daylog.treatPatient (patient2, 20, 40);
    System.out.println ("Number of Patients Arrived: " + daylog.getArrived());
    System.out.println ("Number of Patients Waiting: " + daylog.getNumberWaiting());
    System.out.println ("Waiting position for patient2: " + daylog.findWaitingPosition (patient1));
    System.out.println ("Waiting position for patient2: " + daylog.findWaitingPosition (patient2));
    System.out.println ("Waiting position for patient3: " + daylog.findWaitingPosition (patient3));
    System.out.println ("Waiting position for patient4: " + daylog.findWaitingPosition (patient4));
    System.out.println ("Waiting position for patient5: " + daylog.findWaitingPosition (patient5));

  }
}

For reference if needed, DayLog Class and Patient class

public class DayLog
{
private Date logDate;

private int noOfArrivals = 0;

//Number of waiting patients, different from number of arrived.
private int noOfWaiting = 0;
//Number of patients being treated
private int noOfTreated = 0;

//Sets the size of the waitinglist and treatmentlist arrays
private int waitingListCapacity = 100;
private int treatmentListCapacity = 100;

//Waitlist position for the method findWaitingPosition which is one more than the index.
private int waitlistPosition;

private Patient[] waitingList;
private Patient[] treatmentList;

public DayLog (int day, int month, int year)
{
    logDate = new Date (day, month, year);

    waitingList = new Patient[waitingListCapacity];
    treatmentList = new Patient[treatmentListCapacity];
}

public void addPatient (Patient patient, int hours, int minutes)
{
    patient.setArrivalTime (hours, minutes);

    noOfArrivals++;

    for (int i = 0; i <= waitingList.length-1; i++)
    {
        if ( waitingList[i] == null )
        {
            waitingList[i] = patient;
            noOfWaiting++;
            return;
        }
    }

}

public int getArrived ()
{
    return noOfArrivals;
}

public int getNumberWaiting ()
{
    return noOfWaiting;
}

public int findWaitingPosition (Patient patient)
{
    for ( int i=0; i <= waitingList.length-1; i++)
    {
        if ( waitingList[i] == patient )
        {
            waitlistPosition = i+1;
            return waitlistPosition;
        }
    }

    return -1;
}

public void treatPatient (Patient patient, int hours, int minutes)
{
    for (int i = 0; i <= waitingList.length-1; i++)
    {
        if (waitingList[i] == patient)
        {
            patient.setTreatmentStart (hours, minutes);
            treatmentList[noOfTreated] = patient;
            noOfTreated++;

            for (int j=i; j < noOfWaiting-1; j++ )
            {
                waitingList[j] = waitingList[j+1];
            }

            waitingList[noOfWaiting-1] = null;
            noOfWaiting--;
        }
    }

}

public void printReport ()
{
     System.out.println ("Number of patients arrived: " + noOfArrivals); 
     System.out.println ("Number of patients waiting: " + noOfWaiting ); 
     System.out.println ("Number of being treated: " + noOfTreated);


}

public void printWaitingList ()
{
    for (int i = 0; i <= waitingList.length-1; i++)
    {
        if ( waitingList[i] == null )
        {
        }
        else
        {
            waitingList[i].getAsString();
        }
    }

}

public void printTreatmentList ()
{
    for (int i = 0; i <= treatmentList.length-1; i++)
    {
        if ( treatmentList[i] == null )
        {
        }
        else
        {
            treatmentList[i].getAsString();
        }
    }
}

public double getAverageWaitingTime ()
{
    int sum = 0;
    int count = 0;
    double averageWaitingTime;
    for (int i = 0; i <= treatmentList.length-1; i++)
    {
        if ( treatmentList[i] == null )
        {
        }
        else
        {
            sum += treatmentList[i].getWaitingTime();
            count++;
        }
    }

    averageWaitingTime = (sum / count);
    return averageWaitingTime;

}
          }

Patient class

public class Patient
{
private int patientRefNo;
private String patientName;
private String patientGp;

private Date patientBirthday;

private Time patientArrivalTime;
private Time patientTreatmentTime;

public Patient (int refNo, String name, String gp, int day, int month, int year)
{
    patientRefNo = refNo;
    patientName  = name;
    patientGp    = gp;

    patientBirthday = new Date(day, month, year);

    patientArrivalTime = null;
    patientTreatmentTime = null;

}

protected void setArrivalTime (int hours, int minutes)
{
    patientArrivalTime = new Time (hours, minutes);
}

protected void setTreatmentStart (int hours, int minutes)
{
    patientTreatmentTime = new Time (hours, minutes);
}

public int getPatientNo ()
{
    return patientRefNo;
}

public String getGPName ()
{
    return patientGp;
}

public Date getDOB ()
{
    return patientBirthday;
}

public int getWaitingTime ()
{
    if ( patientArrivalTime == null || patientTreatmentTime == null )
    {

        return -1;
    }
    else
    {

        return patientTreatmentTime.getElapsedTime (patientArrivalTime);
    }
}

public String getAsString ()
{

   System.out.println ("Patient Name: " + patientName);
   System.out.println ("Patient Reference Number: " + patientRefNo);
   System.out.println ("Patient Family Doctor: " + patientGp);
   System.out.println ("Patient Birthday: " + patientBirthday.getAsString());

   if ( patientArrivalTime == null )
   {
       System.out.println ("Patient Arrival Time: this patient has not arrived yet");
   }
   else 
   {
        System.out.println ("Patient Arrival Time: " + patientArrivalTime.getAsString());
   }

   if ( patientTreatmentTime == null )
   {
       System.out.println ("Patient Treatment Time: this patient has not been treated yet");
   }
   else
   {
       System.out.println ("Patient Arrival Time: " + patientTreatmentTime.getAsString());
   }


   return "";
}




}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:59:07+00:00Added an answer on June 14, 2026 at 11:59 pm

    It’s hard to test everything (because as best as I can tell, you have custom Date and Time classes not included here), but if I were to hazard a guess, is there any chance that the window is printing out all of these statements, but there are so many that you can’t see the top ones?

    It’d be quite odd if only some of the System.out.println‘s work; try commenting out a few of the last prints, and check if you can see any of the output from before "Waiting position for patient3".

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the code : import java.io.*; class tester { public static void main(String
This is the code : import java.awt.*; import javax.swing.*; class tester { JFrame fr;
In my header file: Esame(); Esame(string); Esame(string, Voto); This is a c++ tester class:
I am doing this Java assignment for hours and stuck with this tester class
In my current company, we have one tester. Having spoken to this tester, she
I want to my array, somthing like this: array(userid=>username,1=>ganeshfriends,2=>tester) mysql query something like this:
I've got the following structure lib/junit-4.10.jar tests/Tester.java tests/Tester.class build/jar/jar_file.jar (Tester belongs to package tests)
Hi i get a null pointer where marked in the process. The tester class
CODE import java.io.*; class tester { public static void main(String args[]) { try {
ok so this is the assignment that I'm working on: Implement a class Student

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.