using System;
using System.Collections.Generic;
using System.Text;
namespace SmallBasicFun.TicTacToeGame
{
public static class StringUtils
{
private static Random random = new Random();
public static string PrintMany(this IEnumerable many)
{
StringBuilder b = new StringBuilder();
foreach (var m in many)
{
b.AppendFormat("{0}\r\n", m);
}
return b.ToString();
}
public static string DisplayGrid(int width, int height, Func func)
{
StringBuilder b = new StringBuilder(" ");
for (int x = 0; x < width; x++)
{
b.Append(String.Format("{0:0} ", x));
}
b.AppendLine();
for (int y = 0; y < height; y++)
{
b.Append(String.Format("{0:0} ",y));
for (int x = 0; x < width; x++)
{
b.Append(func(x, y)+ " ");
}
b.AppendLine();
}
return b.ToString();
}
public static T GetRandom(this IList items)
{
return items[random.Next(items.Count)];
}
}
}