This is my console simulation of the Slot Machine in C#. Please take a look at this code and point out possible ways of improvement.
using System;
using System.Linq;
namespace Casino
{
class Program
{
public static void Main()
{
SlotMachine slotMachine = new SlotMachine();
slotMachine.Play();
}
}
class SlotMachine
{
private int _tapesCount = 3;
private ConsoleColor _machineColor = ConsoleColor.Red;
public string[] Tapes { get; set; } = {"7", "J", "Q", "K", "A" } ;
public void SetMachineColor(ConsoleColor color)
{
this._machineColor = color;
}
public string[] Play()
{
string[] result = new string[_tapesCount];
Console.ForegroundColor = _machineColor;
Console.Clear();
Console.WriteLine(new string('-', _tapesCount+2));
Console.WriteLine("|" + new string('7', _tapesCount) + "|");
Console.WriteLine(new string('-', _tapesCount+2));
var lastCursorPosition = Console.GetCursorPosition();
Thread.Sleep(1000);
for (int j = 0; j < _tapesCount; j++)
{
Random random = new Random();
for (int i = 0; i < 50; i++)
{
Console.SetCursorPosition(j+1, 1);
string currentTape = Tapes[random.Next(Tapes.Length)];
Console.Write(currentTape);
result[j] = currentTape;
Thread.Sleep(50);
}
}
Console.SetCursorPosition(lastCursorPosition.Item1, lastCursorPosition.Item2);
return result;
}
}
}