//-------------------------------------- // Properties //-------------------------------------- // GETTER / SETTER ///<summary> /// This is a sample getter/setter property. ///</summary> // PUBLIC ///<summary> /// This is a sample public property. ///</summary> // PUBLIC STATIC ///<summary> /// This is a sample public static property. ///</summary> // PRIVATE ///<summary> /// This is a sample private property. ///</summary> // PRIVATE STATIC ///<summary> /// This is a sample private static property. ///</summary> //-------------------------------------- // Methods //-------------------------------------- ///<summary> /// Use this for initialization ///</summary> void Start () { //********************************************************************* // // UNITY WITH COCKTAILS THEME: BEER // //********************************************************************* // DECLARE Beer budweiser_beer = new Beer ("Budweiser", Beer.CONTAINER_TYPE_BOTTLE); // USE Debug.Log ("--------------"); Debug.Log ("budweiser_beer" + budweiser_beer); Beer.SamplePublicStaticMethod ("calling public static method"); budweiser_beer.samplePublicMethod ("calling public method"); // REFLECTION Debug.Log (" type : " + budweiser_beer.GetType()); Debug.Log (" typeof : " + typeof(Beer)); Debug.Log (" (budweiser_beer is Beer): : " + (budweiser_beer is Beer) ); Debug.Log (" (budweiser_beer is Beverage) : " + (budweiser_beer is Beverage) ); // POLYMOPHISM, WE CAN TREAT BEER AND SODA INSTANCES IN A SIMILAR WAY (SOMETIMES) Soda cocaCola_soda = new Soda ("CocaCola"); // Debug.Log ("--------------"); Debug.Log (" beer.name : " + budweiser_beer.name + " with calories " + budweiser_beer.calories); Debug.Log (" soda.name : " + cocaCola_soda.name); }
private double GetSodaPrice(Soda soda) { return(soda.Price); }
public async Task <IActionResult> Post([FromBody] AddItemToCartDTO request) { if (!ModelState.IsValid) { BadRequest(); } var menu = await _context.Menus.FirstOrDefaultAsync(); var pizzaRecipe = menu.PizzaMenu.Where(x => x.MenuNumber == request.PizzaMenuNumber).FirstOrDefault(); var sodaOption = menu.SodaMenu.Where(x => x.MenuNumber == request.SodaMenuNumber).FirstOrDefault(); if (pizzaRecipe == null && sodaOption == null) { return(BadRequest("No items seleceted.")); } else { if (pizzaRecipe != null) { var pizzaToBake = new Pizza() { Id = Guid.NewGuid(), MenuNumber = pizzaRecipe.MenuNumber, Name = pizzaRecipe.Name, Price = pizzaRecipe.Price }; foreach (var ingredient in pizzaRecipe.PizzaIngredients) { var freshIngredient = new Ingredient() { Name = ingredient.Name, IngredientOption = ingredient.IngredientOption, MenuNumber = ingredient.MenuNumber, Price = ingredient.Price }; pizzaToBake.PizzaIngredients.Add(freshIngredient); } _cart.Order.Pizzas.Add(pizzaToBake); } if (sodaOption != null) { var sodaToAdd = new Soda() { Id = Guid.NewGuid(), MenuNumber = sodaOption.MenuNumber, Name = sodaOption.Name, Price = sodaOption.Price }; _cart.Order.Sodas.Add(sodaToAdd); } } return(Ok(new { pizza = (pizzaRecipe == null) ? string.Empty : pizzaRecipe.Name, soda = (sodaOption == null) ? string.Empty : sodaOption.Name })); }
//method add new soda since interfaz public void AddNewSoda(string SodaName, Soda newSoda) { myTree.Insert(SodaName, newSoda); }
public void Post([FromBody] Soda newSoda) { }
private void InsertarNoLleno(Nodo actual, Soda dato) { var i = actual.tamaño - 1; var m = actual.tamaño; //Cuando inserto en rama y si tiene hijos if (!actual.esHoja) { while (i >= 0 && dato.nombre.CompareTo(actual.Llaves[i].nombre) == -1) { actual.Llaves[i + 1] = actual.Llaves[i]; actual.hijos[i + 2] = actual.hijos[i + 1]; i--; } } else { while (i >= 0 && dato.nombre.CompareTo(actual.Llaves[i].nombre) == -1) { actual.Llaves[i + 1] = actual.Llaves[i]; i--; } } actual.Llaves[i + 1] = dato; actual.tamaño++; //Mover hijo si no es hoja if (!actual.esHoja) { var x = i + 1; var c = i + 2; actual.hijos[c] = actual.hijos[x]; actual.hijos[x] = new Nodo(tamanioMax); int j = 0; for (; actual.hijos[c].Llaves[j].nombre.CompareTo(dato.nombre) == -1; j++) { actual.hijos[x].Llaves[j] = actual.hijos[c].Llaves[j]; if (!actual.hijos[c].esHoja) { actual.hijos[x].hijos[j] = actual.hijos[c].hijos[j]; } actual.hijos[c].tamaño--; actual.hijos[x].tamaño++; } int k; for (k = j; k < m; k++) { actual.hijos[c].Llaves[k - j] = actual.hijos[c].Llaves[k]; actual.hijos[c].Llaves[k] = null; if (!actual.hijos[c].esHoja) { actual.hijos[c].hijos[k - j] = actual.hijos[c].hijos[k]; actual.hijos[c].hijos[k] = null; } } if (!actual.hijos[c].esHoja) { actual.hijos[c].hijos[actual.hijos[c].tamaño] = actual.hijos[c].hijos[k - j]; } if (actual.tamaño == tamanioMax - 1) { actual.estaLleno = true; } } }
public void BuildSoda(Soda vsoda) => drink.Soda = vsoda;
private void PartirEn23(Nodo padre, int indexHijoLleno, Soda dato, bool hermanoIzquierdo) { //Si el tiene un padre, el no es raiz int indexLadoIzquierdo = hermanoIzquierdo ? (indexHijoLleno - 1) : indexHijoLleno; int indexLadoDerecho = hermanoIzquierdo ? (indexHijoLleno) : indexHijoLleno + 1; int dosTercios = (tamanioMax * 2) / 3; int indexLlavePadre = hermanoIzquierdo ? (indexHijoLleno - 1) : (indexHijoLleno); int tamañoMaxNodo = tamanioMax - 1; bool esHoja = padre.hijos[indexHijoLleno].esHoja; int j = 0; var arr = new Soda[tamanioMax * 2]; var hijos = new Nodo[tamanioMax * 2]; for (int i = 0; i < tamañoMaxNodo; i++) { arr[j++] = padre.hijos[indexLadoIzquierdo].Llaves[i]; arr[j++] = padre.hijos[indexLadoDerecho].Llaves[i]; } arr[j++] = dato; arr[j++] = padre.Llaves[indexLlavePadre]; if (!esHoja) { int x = 0; for (int i = 0; i < tamanioMax; i++) { hijos[x++] = padre.hijos[indexLadoIzquierdo].hijos[i]; } for (int i = 0; i < tamanioMax; i++) { hijos[x++] = padre.hijos[indexLadoDerecho].hijos[i]; } } j = 0; int k; for (k = 0; k < dosTercios; k++) { padre.hijos[indexLadoIzquierdo].Llaves[k] = arr[j++]; } while (k < tamañoMaxNodo) { padre.hijos[indexLadoIzquierdo].Llaves[k++] = null; padre.hijos[indexLadoIzquierdo].tamaño--; } padre.hijos[indexLadoIzquierdo].estaLleno = false; Soda padre1 = arr[j++]; padre.Llaves[indexLlavePadre] = padre1; for (k = 0; k < dosTercios; k++) { padre.hijos[indexLadoDerecho].Llaves[k] = arr[j++]; } while (k < tamañoMaxNodo) { padre.hijos[indexLadoDerecho].Llaves[k++] = null; padre.hijos[indexLadoDerecho].tamaño--; } padre.hijos[indexLadoDerecho].estaLleno = false; Soda padre2 = arr[j++]; var nuevoNodo = new Nodo(tamanioMax); for (k = 0; j < tamanioMax * 2; k++) { nuevoNodo.Llaves[k] = arr[j++]; nuevoNodo.tamaño++; } var nodoDerecho = padre.hijos[indexLadoDerecho]; if (padre.estaLleno) { if (padre.Padre == null) { partirRaiz(padre); } else { InsertarEnHoja(padre.Padre, padre.indiceHijoDePadre, padre2); } } else { int m = nodoDerecho.Padre.tamaño - 1; for (; m > indexLlavePadre; m--) { nodoDerecho.Padre.hijos[m + 1] = nodoDerecho.Padre.hijos[m + 1]; } nodoDerecho.Padre.Llaves[m + 1] = padre2; nodoDerecho.Padre.hijos[m + 2] = nuevoNodo; nodoDerecho.Padre.tamaño++; nuevoNodo.Padre = nodoDerecho.Padre; nuevoNodo.esHoja = esHoja; } if (nodoDerecho.Padre.tamaño == tamanioMax - 1) { nodoDerecho.Padre.estaLleno = true; } }
public void Insertar(Soda dato) { InsertarNodo(raiz, dato); }
public static void SoakUp(Soda soda) { // TODO: Implement }
public void Post([FromBody] Soda item) { tree.insert(item); }
//DELETE smoothie public Soda Delete(Soda soda) { _db.Execute("DELETE FROM smoothies WHERE id = @Id", soda); return(soda); }