• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with two methods in java  RSS feed

 
Guillermo Rodriguez Barcelo
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem with two methods that are not resolved, I hope you can give me some idea ...

I visit.java have a class with all its builders and all well-defined class this way:


Finally I have the Main1.java well



with this what I want is to implement the methods "Admit" and "printAdmittedVisits" so that when you run the class and call methods
"Admit" and "printAdmittedVisits" screen me out for this:
PATID: 1000000001
ID: 0000000001, PATIENT: 1000000001, SERVICE: CARSRV, LOCATION:
Cardiology Door 1, DOCTOR: Dr. John Heart, DATE: 17/10/2016 10:00
ID: 0000000003, PATIENT: 1000000001, SERVICE: RADSRV, LOCATION:
Radiology Door 25, DOCTOR: Ms. Uranium, DATE: 17/10/2016 08:00
PATID: 1000000002
ID: 0000000002, PATIENT: 1000000002, SERVICE: CARSRV, LOCATION:
Cardiology Door 1, DOCTOR: Dr. John Heart, DATE: 17/10/2016 10:15
PATID: 1000000003
ID: 0000000004, PATIENT: 1000000003, SERVICE: TRASRV, LOCATION:
Traumatology Door 10, DOCTOR: Dr. Joe Bones, DATE: 17/10/2016 10:00
PATID: 1000000004
You don't have any scheduled visit today
PATID: 1000000005
You don't have any scheduled visit today

I'm honestly not tried things but do not know how to approach it, if you could give me some idea would appreciate.

Thank you very much!
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm honestly not tried things but do not know how to approach it, if you could give me some idea would appreciate.

Can you tell us what the admit(..) method is supposed to do.
 
Guillermo Rodriguez Barcelo
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:
I'm honestly not tried things but do not know how to approach it, if you could give me some idea would appreciate.

Can you tell us what the admit(..) method is supposed to do.


The method "Admit" receives the String parameter patiD and asks me when I call method
remove the screen the admission of visits -only
currently those of the day that the person has


For example when you call the method admit ----> admit (visits, "1000000001");
I should return to the screen
ID: 0000000001, PATIENT: 1000000001, SERVICES: CARSRV, LOCATION:
Cardiology door 1, doctor: Dr. John heart DATE: 17/10/2016 10:00
ID: 0000000003, PATIENT: 1000000001, SERVICES: RADSRV, LOCATION:
Radiology gate 25, Doctor: Mrs. uranium DATE: 17/10/2016 8:00

Me this drawing of your upcoming appointments for today the patient, in this case puts 10/17/2016 that I have it as well, but
I do it for today's date.

Thank you!
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I fully understand the requirements but the first things is you need to do is print the "Visits" for the given patient ID so you will need to iterate over the visits array using some form of loop and check each Visit object to see if it matches the given patient ID and if so print out it's details.

I suggest you get this part working before moving onto the next part of the requirement.
 
Guillermo Rodriguez Barcelo
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:I'm not sure I fully understand the requirements but the first things is you need to do is print the "Visits" for the given patient ID so you will need to iterate over the visits array using some form of loop and check each Visit object to see if it matches the given patient ID and if so print out it's details.

I suggest you get this part working before moving onto the next part of the requirement.


Well I advance, I got out on screen each patient visits as follows



This is what gets me is the following

PATID: 1000000001
ID: 0000000001, PATIENT: 1000000001, SERVICE: CARSRV, LOCATION: Cardiology Door 1, DOCTOR: Dr. John Heart, DATE: 17/10/2016 10:00
ID: 0000000003, PATIENT: 1000000001, SERVICE: RADSRV, LOCATION: Radiology Door 25, DOCTOR: Ms. Uranium, DATE: 17/10/2016 08:00
ID: 0000000005, PATIENT: 1000000001, SERVICE: TRASRV, LOCATION: Traumatology Door 11, DOCTOR: Dr. Mary Legs, DATE: 18/10/2016 10:00
PATID: 1000000002
ID: 0000000002, PATIENT: 1000000002, SERVICE: CARSRV, LOCATION: Cardiology Door 1, DOCTOR: Dr. John Heart, DATE: 17/10/2016 10:15
PATID: 1000000003
ID: 0000000004, PATIENT: 1000000003, SERVICE: TRASRV, LOCATION: Traumatology Door 10, DOCTOR: Dr. Joe Bones, DATE: 17/10/2016 10:00
PATID: 1000000004
PATID: 1000000005


But now what I want is to control that if the date is not today I should not make the appointment ...

As I compare the system date with the date that I pass by parameter ??

I advance even with doubts but gradually ...>
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You shouldn't compare String (or any object for that matter) using == always use .equals() unless you really want to test if the object references rather than the object states are the same - AvoidTheEqualityOperator (← click).
 
Guillermo Rodriguez Barcelo
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:
You shouldn't compare String (or any object for that matter) using == always use .equals() unless you really want to test if the object references rather than the object states are the same - AvoidTheEqualityOperator (← click).


Ok, you're absolutely right, it just changed and is as follows:



Now I'm trying to do not remove all if not only today's date.

Now I'm trying to do not remove all if not only today's date

Any idea to get the system date and then compare it with the parameter I pass by?
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using Java 8 or later then use the new DateTime classes - see this tutorial https://docs.oracle.com/javase/tutorial/datetime/
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!