コード例 #1
0
ファイル: Program.cs プロジェクト: lyubomirp/Homework
        static void Main(string[] args)
        {
            identifiabls = new List <IBuyable>();
            int count = int.Parse(Console.ReadLine());



            for (int i = 0; i < count; i++)
            {
                string[] inputData = Console.ReadLine()
                                     .Split();
                FeedInput(inputData);
            }

            string buyer = Console.ReadLine();

            while (buyer != "End")
            {
                IBuyable tuBuy = identifiabls.Find(x => x.Name == buyer);
                if (tuBuy != null)
                {
                    tuBuy.BuyFood();
                }
                buyer = Console.ReadLine();
            }

            Console.WriteLine(identifiabls.Sum(x => x.GetFood));
        }
コード例 #2
0
ファイル: GameEconomy.cs プロジェクト: Cromwill/Project-Ball
 public void OnPurchaseCompleted(IBuyable buyable)
 {
     _scorreCounter.ReductionScorre(GetPrice(buyable.Price, buyable.ObjectType));
     ObjectOnScene.AddCount(buyable.ObjectType);
     GameDataStorage.SaveObjectsOnScene(ObjectOnScene);
     PurchaseCompleted?.Invoke();
 }
コード例 #3
0
 public static void Buy(IBuyable buyableScript)
 {
     if (buyableScript.Price() <= gold)
     {
         GoldExtraction(buyableScript.Price());
     }
 }
コード例 #4
0
 private void FillMarketCategory(ProductFactory productFactory, Enum productType)
 {
     foreach (Enum type in Enum.GetValues(productType.GetType()))
     {
         IBuyable ingredient = productFactory.Get(type);
         this.market.AddProduct(ingredient);
     }
 }
コード例 #5
0
        private void BNormalUser_Click(object sender, EventArgs e)
        {
            IBuyable             buyable = controllerSO.storeOwner;
            NormalUserController normalUserController = new NormalUserController(controllerSO.storeOwner);
            NUserPage            nUserPage            = new NUserPage(normalUserController, controllerSO.storeOwner.controllerCart, buyable);

            nUserPage.Show();
        }
コード例 #6
0
ファイル: Character.cs プロジェクト: maddox96/2DPlatformerRPG
        public bool enoughMoney(IBuyable obj)
        {
            if (Money - obj.cost > 0)
            {
                return(true);
            }

            return(false);
        }
コード例 #7
0
 public static bool GoldIsEnoughToBuy(IBuyable buyableScript)
 {
     if (buyableScript.Price() <= gold)
     {
         return(true);
     }
     else
     {
         FloatingTextController.CreateWarningText("The current money is not enough to buy");
         return(false);
     }
 }
コード例 #8
0
ファイル: Character.cs プロジェクト: maddox96/2DPlatformerRPG
        public void spendMoney(IBuyable obj)
        {
            if (enoughMoney(obj))
            {
                Money -= obj.cost;
            }

            if (OnMoneySpend != null)
            {
                OnMoneySpend();
            }
        }
コード例 #9
0
        public bool Buy(IBuyable item, int amount = 1)
        {
            int totalPrice = item.BuyPrice * amount;

            if (Currencies[item.Currency].Value < totalPrice)
            {
                return(false);
            }

            SetCurrencyValue(item.Currency, Currencies[item.Currency].Value - totalPrice);
            return(true);
        }
コード例 #10
0
        //Handles purchase and updates item inventory and remaining balance of customer
        public void PurchaseProcess(VendingMachine vm)
        {
            bool makingSelection = true;

            while (makingSelection)
            {
                string quantity = "";

                foreach (KeyValuePair <string, IBuyable> item in vm.InventoryList)
                {
                    if (item.Value.Quantity == 0)
                    {
                        quantity = "SOLD OUT";
                    }
                    else
                    {
                        quantity = item.Value.Quantity.ToString();
                    }
                    Console.WriteLine($"\t\t{item.Key} {item.Value.Name} ${item.Value.Price} Qty. ({quantity})");
                }
                string customerSelection = Console.ReadLine();
                if (!vm.InventoryList.ContainsKey(customerSelection))
                {
                    Console.WriteLine("Product code does not exist");
                }
                else if (vm.InventoryList.ContainsKey(customerSelection) && quantity == "SOLD OUT")
                {
                    Console.WriteLine("Product is sold out. We apologize for the inconvenience.");
                }
                else if (vm.InventoryList.ContainsKey(customerSelection))
                {
                    IBuyable buyable = vm.InventoryList[customerSelection];
                    if (buyable.Price > vm.Balance)
                    {
                        Console.WriteLine("INSUFFICIENT FUNDS");
                        makingSelection = false;
                    }
                    else if (buyable.Price < vm.Balance)
                    {
                        buyable.Quantity--;
                        vm.Balance -= buyable.Price;
                        Console.WriteLine($"{buyable.Name} {buyable.Price} Balance: {vm.Balance}");
                        Console.WriteLine(buyable.MakeYum());
                        makingSelection = false;
                        audit.AuditPurchases(buyable.Name, customerSelection, vm.Balance);
                    }
                }
            }
        }
コード例 #11
0
        public void BuyProducts(IBuyable product, int quantity, Market market)
        {
            int cost     = market.CalculateCost(product, quantity);
            var currency = this.GetFromInventoryByType(FarmFoodType.Raspberry);

            if (currency != null && this.Inventory[currency] >= cost)
            {
                this.Inventory[currency] -= cost;
            }
            else
            {
                throw new InsufficientAmmountException(currency.ToString());
            }

            this.AddToInventory(product);
        }
コード例 #12
0
        public void BuyProducts(IBuyable product, int quantity, Market market)
        {
            int cost = market.CalculateCost(product, quantity);
            var currency = this.GetFromInventoryByType(FarmFoodType.Raspberry);

            if (currency != null && this.Inventory[currency] >= cost)
            {
                this.Inventory[currency] -= cost;
            }
            else
            {
                throw new InsufficientAmmountException(currency.ToString());
            }

            this.AddToInventory(product);
        }
コード例 #13
0
ファイル: Cart.cs プロジェクト: AhmedNabih/OnlineStore
        public Cart(ShoppingCartController cartController, NormalUserController controller, IBuyable buyable, string s, string amount, string statID)
        {
            // My Online MSQL DataBase
            String connectionStr = "Data Source=SQL5047.site4now.net;Initial Catalog=DB_A5071D_OnlineStore;User Id=DB_A5071D_OnlineStore_admin;Password=01152160972Ah;";
            // Local MSQL DataBase
            //String connectionStr = "Data Source=DESKTOP-JEM2R23\\;Initial Catalog=OnlineStore;Integrated Security=True";

            IConnectionString connectionString = new DataBaseConnection();

            connectionString.SetConnectionString(connectionStr);
            this.buyable = buyable;
            InitializeComponent();
            this.cartController = cartController;
            this.controller     = controller;
            ListItem            = cartController.viewCart();
            this.StoreID        = s;
            this.Actualamount   = amount;
            this.statID         = statID;
            this.querie         = new ShoppingCartControllerQueries(connectionString);
        }
コード例 #14
0
        static IItem ChooseItem(List <IItem> items)
        {
            while (true)
            {
                Console.WriteLine("-------------------------------");


                var index = 1;
                foreach (IItem item in items)
                {
                    Console.Write("[{0}] - {1} ", index, item.Name);

                    IBuyable buyable = item as IBuyable;
                    if (buyable != null)
                    {
                        Console.Write("- costs {0}", buyable.Price);
                    }

                    if (item is IMovable)
                    {
                        Console.Write("- can move");
                    }

                    Console.WriteLine();

                    index++;
                }

                Console.Write("Choose item: ");
                var itemIndex = int.Parse(Console.ReadLine());

                if (itemIndex <= 0 || itemIndex > items.Count)
                {
                    Console.WriteLine("You are dumb");
                    continue;
                }

                return(items[itemIndex - 1]);
            }
        }
コード例 #15
0
ファイル: NUserPage.cs プロジェクト: AhmedNabih/OnlineStore
        public NUserPage(NormalUserController user, ShoppingCartController cartController, IBuyable buyable)
        {
            // My Online MSQL DataBase
            String connectionStr = "Data Source=SQL5047.site4now.net;Initial Catalog=DB_A5071D_OnlineStore;User Id=DB_A5071D_OnlineStore_admin;Password=01152160972Ah;";
            // Local MSQL DataBase
            //String connectionStr = "Data Source=DESKTOP-JEM2R23\\;Initial Catalog=OnlineStore;Integrated Security=True";

            IConnectionString connectionString = new DataBaseConnection();

            connectionString.SetConnectionString(connectionStr);
            queries         = new ShoppingCartControllerQueries(connectionString);
            this.controller = user;
            InitializeComponent();
            TuserName.Text         = controller.normalUser.Data.userName;
            Temail.Text            = controller.normalUser.Data.email;
            Tname.Text             = controller.normalUser.Data.name;
            Trole.Text             = controller.normalUser.Data.role;
            this.cartController    = cartController;
            this.buyable           = buyable;
            cartObject             = new CartItem();
            controllerStoreProduct = new StoreProductController();
        }
コード例 #16
0
    void Awake()
    {
        buyable     = GetComponent <IBuyable>();
        text        = GetComponentInChildren <TextMeshPro>();
        moneyHolder = objective.GetComponent <MoneyHolder>();

        if (File.Exists(Application.persistentDataPath + "/rbSave.bp"))
        {
            levelOfTheElement = SaveLoad.saveGame.data.playerUpgrades[(int)buyable.GetBuyable()];
            for (int i = 0; i < levelOfTheElement; i++)
            {
                LevelUpThePrice();
            }
        }
        else
        {
            levelOfTheElement = 0;
        }

        text.text = "" + priceOfTheElement;

        switch ((SceneEnum)System.Enum.Parse(typeof(SceneEnum), SceneManager.GetActiveScene().name))
        {
        case SceneEnum.Level1:
            actualLevelScene = 1;
            break;

        case SceneEnum.Level2:
            actualLevelScene = 2;
            break;

        case SceneEnum.Level3:
            actualLevelScene = 3;
            break;
        }
    }
コード例 #17
0
 public void RemoveProduct(IBuyable product)
 {
     this.BuyableProducts.Remove(product);
 }
コード例 #18
0
 public void AddProduct(IBuyable product)
 {
     this.BuyableProducts.Add(product);
 }
コード例 #19
0
 public void AddProduct(IBuyable product)
 {
     this.BuyableProducts.Add(product);
 }
コード例 #20
0
 public OrderItem(IOrder order, IBuyable product, int quantity) : this(order, product)
 {
     this.Quantity = quantity;
 }
コード例 #21
0
 public void RemoveProduct(IBuyable product)
 {
     this.BuyableProducts.Remove(product);
 }
コード例 #22
0
 public OrderItem(IOrder order, IBuyable product) : this(order)
 {
     this.Product  = product;
     this.Quantity = 1;
 }