static void Main(string[] args) { Rectangle rect = new Rectangle(); double x = 200; double y = 300; Console.WriteLine("矩形的面积为:{0}", rect.Area(x, y)); Console.WriteLine("矩形的周长为:{0}", rect.Perimeter(x, y)); Console.ReadKey(); }
static void Main(string[] args) { //求圆面积,跟矩形周长和面积,使用抽象类的方法实现 Calculate Cyl = new Circle(5.3); Console.WriteLine(Cyl.Area()); Console.WriteLine(Cyl.Perimeter()); Calculate Rec = new Rectangle(5, 3); Console.WriteLine(Rec.Area()); Console.WriteLine(Rec.Perimeter()); }
static void Main(string[] args) { for (int i = 0; i < 4; i++) { int h; int w; Console.WriteLine("print h"); h = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("print w"); w = Convert.ToInt32(Console.ReadLine()); //объект создать здесь. Rectangle R1 = new Rectangle(h, w); R1.Area(); } Console.ReadKey(); }