/ Published in: Java
here is a desciption
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// ensure the boardcomponent isn't an instance of Chinese whispers if (!(bC instanceof BloodBankNote) || !(bC instanceof DonorNote)) { //check which type of object the boardcomponent is if (bC instanceof BloodBank) { //in this section you'll need to loop through all the mailboxes to ensure you add the message for everyone (excluding yourself) //add the message to the mailbox, creating the new object (extension of bloodbank) inline. mailbox[i].add(new Message(this.getIdNumber(), new BloodBankNote(this.getIdNumber(), ((BloodBank) bC)))); } } // you'll see 2 levels of casting brackets to be able to use an object inline instead of having to create a new object first ((BloodBank) bC) see there are brackets around the casting type (BloodBank) and then a second set of brackets around WHAT is being cast (which encompasses the casting type)