Return to Snippet

Revision: 66516
at May 18, 2014 09:46 by Therita


Initial Code
// 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)

Initial URL


Initial Description
here is a desciption

Initial Title
BloodBank Agent - Messaging

Initial Tags


Initial Language
Java