From bc7f2da77576a2b2b124dc8a8f7382f5ab7c6c41 Mon Sep 17 00:00:00 2001 From: MarcUs7i <96580944+MarcUs7i@users.noreply.github.com> Date: Sat, 16 Nov 2024 19:48:16 +0100 Subject: [PATCH] Initialized the CoffeeVendingMachine.cs class Rewrote from get/set like in the README --- CoffeeVendingMachines/CoffeeVendingMachine.cs | 87 +++++++++++++++++++ CoffeeVendingMachines/CoinDepot.cs | 2 +- CoffeeVendingMachines/Product.cs | 5 +- 3 files changed, 91 insertions(+), 3 deletions(-) diff --git a/CoffeeVendingMachines/CoffeeVendingMachine.cs b/CoffeeVendingMachines/CoffeeVendingMachine.cs index 64e5575..ee791ed 100644 --- a/CoffeeVendingMachines/CoffeeVendingMachine.cs +++ b/CoffeeVendingMachines/CoffeeVendingMachine.cs @@ -2,5 +2,92 @@ public class CoffeeVendingMachine { + private static readonly CoinType[] withdrawalOrder; + private readonly CoinDepot[] _currentChangeCoins; + private readonly CoinDepot[] _currentInputCoins; + private readonly Product[] _products; + + public readonly string Location; + public readonly int TotalChangeAmountInMachine; + public readonly int TotalMoneyCurrentlyInput; + public readonly Product[] AvailableProducts; + + public CoffeeVendingMachine(CoinDepot[] coinDepots, Product[] products, string location) + { + //TODO + } + + public CoffeeVendingMachine(string location) + { + //TODO + } + + public CoinDepot[] Cancel() + { + //TODO + return []; + } + public bool InsertCoin(CoinType coin) + { + //TODO + return false; + } + + public bool SelectProduct(string productName, out CoinDepot[]? change, out int? price) + { + //TODO + change = null; + price = null; + return false; + } + + public override string ToString() + { + //TODO + return ""; + } + + private void AddInputToChange() + { + //TODO + } + + private static CoinDepot[] CreateCoinDepots(int count) + { + //TODO + return []; + } + + private static Product[] CreateDefaultProducts() + { + //TODO + return []; + } + + private static CoinDepot? GetDepotByType(CoinDepot[] coinDepots, CoinType coinType) + { + //TODO + return null; + } + + private int? PrepareChangeCoins(int amount, out CoinDepot[] changeCoins) + { + //TODO + changeCoins = []; + return null; + } + + private static int SumDepotValue(CoinDepot[] coinDepots) + { + //TODO + return 0; + } + + private bool TryFindProduct(string productName, out Product? product) + { + //TODO + product = null; + return false; + } } diff --git a/CoffeeVendingMachines/CoinDepot.cs b/CoffeeVendingMachines/CoinDepot.cs index dbd6fd2..f51b62a 100644 --- a/CoffeeVendingMachines/CoinDepot.cs +++ b/CoffeeVendingMachines/CoinDepot.cs @@ -2,7 +2,7 @@ namespace CoffeeVendingMachines; public class CoinDepot { - public CoinType Coin { get; } + public readonly CoinType Coin; public int Count { get; private set; } public CoinDepot(CoinType coin, int count = 0) diff --git a/CoffeeVendingMachines/Product.cs b/CoffeeVendingMachines/Product.cs index c3dbf64..47d021a 100644 --- a/CoffeeVendingMachines/Product.cs +++ b/CoffeeVendingMachines/Product.cs @@ -5,8 +5,8 @@ public class Product public const int FallbackPrice = 50; private readonly int _price; private int _stock; - public bool InStock => _stock > 0; - public string Name { get; } + public readonly bool InStock; + public readonly string Name; public int NumberSold { get; private set; } public int Price { get; private init; } @@ -15,6 +15,7 @@ public class Product Name = name; _price = price; _stock = stock; + InStock = _stock > 0; } public bool AddSale()