using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace NonoGramme { internal class Line { private static Random rnd = new Random(); private Tile[] _data; private int _length; private List _hints; public Tile[] Data { get => _data; set => _data = value; } public int Length { get => _length; set => _length = value; } public List Hints { get => _hints; set => _hints = value; } public Line(Tile[] states) { //This method will create a new Line wich can then be edited Data = states; RecalculateHints(); } public Line(int length) { //This method will just create the Line but totally empty Length = length; Data = new Tile[Length]; for (int i = 0; i< Length; i++) { Data[i] = new Tile(); } RecalculateHints(); } public string GetHorizontalHints() { string result = ""; int counter = 0; foreach (int hint in Hints) { counter++; if (counter != Hints.Count) { result += hint + ","; } else { result += hint; } } return result; } public string GetVerticalHints() { string result = ""; foreach (int hint in Hints) { result += hint + Environment.NewLine; } return result; } public void Edit(int index, Tile.State state) { Data[index].CurrentState = state; RecalculateHints(); } public void RecalculateHints() { //This will have to be done, for now its just a placeholder //TO REMOVE !! Hints = new List(); int count = rnd.Next(1, Data.Count()-1); for (int i = 0;i < count;i++) { Hints.Add(rnd.Next(1, Data.Count()-1)); } } } }