using System;
namespace Tables2
{
class CoffeeTable : Table
{
public CoffeeTable(float width, float height)
{
this.width = width;
this.height = height;
}
public override void ShowData()
{
Console.WriteLine("(Coffee table) Width: {0}, Heigth: {1}", width, height);
}
}
class Table
{
protected float width, height;
public Table()
{
}
public Table(float width, float height)
{
this.width = width;
this.height = height;
}
public float Width
{
set { width = value; }
get { return width; }
}
public float Height
{
set { height = value; }
get { return height; }
}
public virtual void ShowData()
{
Console.WriteLine("Width: {0}, Heigth: {1}", width, height);
}
}
class TestTables
{
static void Main()
{
bool debug = false;
Table[] myTables = new Table[10];
Random rnd = new Random();
for (int i = 1; i <= 10; i++)
{
if ((i % 2 == 0) && (i != 1))
{
myTables[i - 1] = new Table(rnd.Next(50, 201), rnd.Next(50, 201));
myTables[i - 1].ShowData();
}
else
{
myTables[i - 1] = new CoffeeTable(rnd.Next(40, 121), rnd.Next(40, 121));
myTables[i - 1].ShowData();
}
}
if (debug)
Console.ReadLine();
}
}
}