using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace QwirkleClassLibrary.Tiles
{
[DataContract]
public class Tile : IComparable
{
[DataMember]
private readonly Shape shape;
[DataMember]
private readonly Color color;
///
/// This is the constructor for a Tile.
///
/// The shape of the tile.
/// The color of the tile.
public Tile(Shape sh, Color co)
{
shape = sh;
color = co;
}
///
/// This method is used to return the color and the shape into a string.
///
/// A string with the color and the shape of the tile.
public string NameColorTile()
{
return color.ToString() + shape.ToString();
}
///
/// A getter for the shape of the Tile.
///
/// The shape attribute of the Tile.
public Shape GetShape
{
get { return shape; }
}
///
/// A getter for the color of the Tile.
///
/// The color attribute of the Tile.
public Color GetColor
{
get { return color; }
}
///
/// This method is used to override the ToString() method. It is simply a tool to facilitate the development.
///
/// The color and the shape of the tile, spaced, in a string format.
public override string ToString()
{
return color.ToString() + " " + shape.ToString();
}
public int CompareTo(object? obj)
{
if (obj == null) return 1;
var otherTile = obj as Tile;
if (otherTile != null)
{
if (color == otherTile.color)
{
return shape.CompareTo(otherTile.shape);
}
return color.CompareTo(otherTile.color);
}
throw new ArgumentException("Object is not a Tile");
}
}
}