//give a ressource named "name" to "island", with a stock of "quantity"
 //if the ressource didn't exist on "island", it is created
 public void giveRessource(string name, Island island, int quantity)
 {
     Ressource ressource = new Ressource(name, quantity);
     if (island.getRessource(name) == null)  //the island doesn't have this ressource
     {
         island.ressources.Add(new Ressource(name));
         island.getRessource(name).stock = quantity;
     }
     else    //the island has this ressource
     {
         island.getRessource(name).stock += quantity;
     }
 }
 //withdraw a stock of "quantity" from a ressource named "name" of "island"
 //returns the effectively quantity withdrawn (if stock=5 & quantity=7, it returns 5)
 public int withdrawRessource(string name, Island island, int quantity)
 {
     Ressource ressource = island.getRessource(name);
     if (ressource == null)  //if the ressource doesn't exist on the island
         return 0;
     if (ressource.stock <= quantity)
     {
         int temp = ressource.stock;
         ressource.stock = 0;
         return temp;
     }
     else
     {
         ressource.stock -= quantity;
         return quantity;
     }
 }
 //consume the ressourceNeedded and produce the ressourceProduced (only if there was still a stock of ressourceNeedded)
 //method called by an Island, each 10 seconds while the state of the building is 1
 public void consume_produce(Island island)
 {
     RessourceManager rm = new RessourceManager();
     //checks if the ressourceNeeded exists and if there is enough of its stock
     if ((island.getRessource(ressourceNeeded) != null) && (island.getRessource(ressourceNeeded).stock >= consumptionCost))  
     {
         rm.withdrawRessource(ressourceNeeded, island, consumptionCost); //consumption
         rm.giveRessource(ressourceProduced, island, productionCost);    //production
         System.Diagnostics.Debug.WriteLine("Le batiment " + this.name + " utilise " + this.consumptionCost.ToString() + " " + this.ressourceNeeded + " et produit " + this.productionCost.ToString() + " " + this.ressourceProduced + " sur l'ile " + island.id.ToString());
     }    
     else
     {
         System.Diagnostics.Debug.WriteLine("Le batiment " + this.name + " ne peut plus produire de " + this.ressourceProduced + " car il ne reste pas assez de " + ressourceNeeded + " sur l'ile " + island.id.ToString());
     }        
 }