static void Main(string[] args) { Rectangular uxxankyun = new Rectangular(10, 20, "uxxankyun"); Console.WriteLine(uxxankyun.Area()); Triangel erankyun = new Triangel(10, 20, "erankyun"); Console.WriteLine(erankyun.Area()); Circule shrjan = new Circule(10, "shrjan"); Console.WriteLine(shrjan.Area()); Console.ReadKey(); }
public Shape GetShape(int type) { switch (type) { case 0: return(new Rec(10 * r.NextDouble(), 10 * r.NextDouble())); case 1: return(new Square(10 * r.NextDouble())); case 2: //三角形的生成还需要判断 Triangel t = new Triangel(10 * r.NextDouble(), 10 * r.NextDouble(), 10 * r.NextDouble()); while (!t.isLegal()) { t = new Triangel(10 * r.NextDouble(), 10 * r.NextDouble(), 10 * r.NextDouble()); } return(t); default: return(null); } }