This SHOULD BE the console:
Jordan d34
d34 Jordan
Jordan null
d34 null
Jordan d34
d34 Jordan
Jordan null
d34 null
Type: Posts; User: TmDee
This SHOULD BE the console:
Jordan d34
d34 Jordan
Jordan null
d34 null
Jordan d34
d34 Jordan
Jordan null
d34 null
I think my code says.
Make a Patient with naam: Jordan.
Then make a bed with nummer d34.
Then setBed(b1) does sets the number d34 to patient p1.
So when we print out p1 it return naam: Jordan...
Yes thank you I get that but I sorry, I can't see in my code where an variable is null, before I use a method to delete an variable.
Okay, I see but I still don't get it why it gives that null error, I probably should just wait and ask to my prof
Yes indeed it becomes null with the method, verwijderBed then it's says the value to zero but never before. I don't see it where it is null in the beginning do you?
I don't know why it's null, none of the variables is null from the object I try to print out.
The console should be:
Jordan d34
d34 Jordan
Jordan null
d34 null
Jordan d34
Don't get how it can give null value if I print the variables b1.getNummer() en p1.getNaam() it gives the values I want but when I put it in the toString methode it gives an error like you said a...
public class Bed {
private String nummer;
private Patient patient;
public String toString() {
return nummer +" " + patient.getNaam();
}
public Bed(String num) {
I searched a bit more but apparently it's an excercise about a subject that we haven't learn yet, so i'll be probably in the weekend back on to this!
I see so I deleted this from line 7 for both classes and it only prints out
Jordan
d34
Jordan
d34
Jordan
d34
Jordan
This is the main:
public class main {
public static void main(String[] args) {
Patient p1 = new Patient("Jordan");
Bed b1 = new Bed("d34");
p1.setBed(b1);
System.out.println(p1);...