This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IVendingMachineView | |
{ | |
event EventHandler CoinInserted; | |
event EventHandler Cancel; | |
event EventHandler Select; | |
event EventHandler<NumberEnteredArgs> NumberEntered; | |
void ShowMessage(string message); | |
void AddProduct(string code, Product p); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class VendingMachine | |
{ | |
private Dictionary<string, Product> _products = new Dictionary<string, Product>() | |
{ | |
{ "01", new Product("Product 01", 3, 5)}, | |
{ "02", new Product("Product 02", 2, 1)}, | |
{ "03", new Product("Product 03", 1, 0)}, | |
{ "11", new Product("Product 04", 4, 0)}, | |
{ "12", new Product("Product 05", 1, 5)}, | |
{ "13", new Product("Product 06", 1, 5)}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class VendingMachine | |
{ | |
private Dictionary<string, Product> _products = new Dictionary<string, Product>() | |
{ | |
{ "01", new Product("Product 01", 3, 5)}, | |
{ "02", new Product("Product 02", 2, 1)}, | |
{ "03", new Product("Product 03", 1, 0)}, | |
{ "11", new Product("Product 04", 4, 0)}, | |
{ "12", new Product("Product 05", 1, 5)}, | |
{ "13", new Product("Product 06", 1, 5)}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AvailabilityChangedArgs : EventArgs | |
{ | |
public bool SoldOut { get; } | |
public AvailabilityChangedArgs(bool soldOut) | |
{ | |
SoldOut = soldOut; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Product | |
{ | |
private int _available; | |
public event EventHandler AvailabilityChanged; | |
public Product(string name, int coins, int available) | |
{ | |
Name = name; | |
Coins = coins; | |
Available = available; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ProductView : MonoBehaviour | |
{ | |
[SerializeField] | |
private Text _code; | |
[SerializeField] | |
private Text _name; | |
[SerializeField] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace VendingMachines | |
{ | |
public class VendingMachineBehaviour : MonoBehaviour | |
{ | |
#region Serialized Fields | |
[SerializeField] | |
private Text _message; | |
[SerializeField] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace VendingMachines | |
{ | |
public class Product | |
{ | |
public Product(string name, int coins, int available) | |
{ | |
Name = name; | |
Coins = coins; | |
Available = available; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Utils | |
{ | |
public class ShowMessages : MonoBehaviour | |
{ | |
[SerializeField] | |
private Text _message; | |
private TimedQueue<string> queue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UI; | |
namespace Utils | |
{ | |
public class ShowMessages : MonoBehaviour | |
{ | |
[SerializeField] |
NewerOlder