public void Overwrite(string query, string id, string description, string pack) { //Method to overwrite an item at a certain ID //Fill out the information for the new item FullBeverage replacement = new FullBeverage(); replacement.id = id; replacement.name = description; replacement.pack = pack; int i = 0; bool found = false; while (!found) {//This method just finds the index of the beverages array that the item to replace is at if (beverages[i].id == query) { found = true; } else { i++; } } //And finally we actually replace the item beverages[i] = replacement; }
//Add a new item to the collection public void AddNewItem(string id, string description, string pack) { //Add a new WineItem to the collection. Increase the Length variable. FullBeverage bevToAdd = new FullBeverage(); bevToAdd.id = id; bevToAdd.name = description; bevToAdd.pack = pack; beverages[wineItemsLength] = bevToAdd; wineItemsLength++; }