Posted By

Therita on 05/18/14


Tagged


Versions (?)

BloodBank Agent - Messaging


 / Published in: Java
 

here is a desciption

  1. // ensure the boardcomponent isn't an instance of Chinese whispers
  2. if (!(bC instanceof BloodBankNote) || !(bC instanceof DonorNote)) {
  3. //check which type of object the boardcomponent is
  4. if (bC instanceof BloodBank) {
  5.  
  6.  
  7. //in this section you'll need to loop through all the mailboxes to ensure you add the message for everyone (excluding yourself)
  8.  
  9. //add the message to the mailbox, creating the new object (extension of bloodbank) inline.
  10. mailbox[i].add(new Message(this.getIdNumber(), new BloodBankNote(this.getIdNumber(), ((BloodBank) bC))));
  11.  
  12. }
  13. }
  14.  
  15.  
  16. // 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)

Report this snippet  

You need to login to post a comment.