Advertisement
PotiSolhdoost

Untitled

Aug 13th, 2023
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Order
  6. {
  7.     public List<Pizza> pizzas {  get; private set; } = new List<Pizza>();
  8.  
  9.     public Order()
  10.     {
  11.         int pizzaCount = Random.RandomRange(1, 6);
  12.         for(int i = 0; i < pizzaCount; i++)
  13.         {
  14.             Pizza.PizzaType randomType = (Pizza.PizzaType)Random.Range(0, System.Enum.GetValues(typeof(Pizza.PizzaType)).Length);
  15.             pizzas.Add(new Pizza(randomType));
  16.         }
  17.     }
  18.  
  19.     public float CalculateTotalCookingTime(Equipment equipment)
  20.     {
  21.         float totalCookingTime = 0;
  22.         foreach( Pizza pizza in pizzas )
  23.         {
  24.             totalCookingTime += pizza.CookingTime * equipment.GetCookingTimeMultiplier();
  25.         }
  26.         return totalCookingTime;
  27.     }
  28.     public float CalculateTotalPrice()
  29.     {
  30.         float totalPrice = 0;
  31.         foreach(Pizza pizza in pizzas )
  32.         {
  33.             totalPrice += pizza.Price;
  34.         }
  35.         return totalPrice;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement