update method

void update (Catalogue upToDateCatalogue)

Updates the chosenQuantity fields in all the elements of the catalogue based on the locallyChosenQuantyty fields. It takes an up-to-date Catalogue instance, syncronized with Firestore, and adds up the quantity of every element chosen by the participants.

Implementation

void update(Catalogue upToDateCatalogue) {
  debugPrint('\nIn update:\nupToDateCatalogue:');
  upToDateCatalogue.printCatalogue();
  debugPrint('\nlocalCatalogue:');
  printCatalogue();
  for (int i = 0; i < this.catalogue.length; ++i) {
    for (int j = 0; j < this.catalogue[i].length; ++j) {
      catalogue[i][j].chosenQuantity += upToDateCatalogue.catalogue[i][j].locallyChosenQuantity;
    }
  }
}