请大家帮忙看一下这段程序哪里不对了?
有这样一个问题:定义一个Shape抽象类,作用它作为基类派生出Rectanle 、Circle等具体形状类,已知具体形状类均具有两个方法,分别用来求形状的面积和周长。运行界面如附件中所示,程序代码编写如下: using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace shape
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public class Shape
{
public virtual double GetArea()
{
return (0);
}
public virtual double GetPerim()
{
return (0);
}
}
class Rectangle : Shape
{
public double Width;
public double Length;
public Rectangle(double a, double b)
{
Width = a;
Length = b;
}
public override double GetArea()
{
return (Width * Length);
}
public override double GetPerim()
{
return (2 * (Width + Length));
}
}
class Circle : Shape
{
public double Radius;
public Circle(double r)
{
Radius = r;
}
public override double GetArea()
{
return (Math.PI * Radius * Radius);
}
public override double GetPerim()
{
return (2 * Math.PI * Radius);
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
double a,b;
a = Convert.ToDouble(textBox1.Text);
b = Convert.ToDouble(textBox2.Text);
Rectangle Rect=new Rectangle (a,b);
textBox3.Text = Rec.GetPerim().ToString();
textBox4.Text = Rec.GetAera().ToString();
}
private void button2_Click(object sender, EventArgs e)
{
double r;
r = Convert.ToDouble(textBox5.Text);
Circle Cir = new Circle(r);
textBox6.Text = Cir.GetPerim().ToString();
textBox7.Text = Cir.GetArea().ToString();
}
}
}
但是程序在编译时提示了这样一堆错误:
错误 1 应输入 class、delegate、enum、interface 或 struct G:\visualstudio\shape\shape\Form1.cs 64 17 shape
错误 2 应输入 class、delegate、enum、interface 或 struct G:\visualstudio\shape\shape\Form1.cs 69 17 shape
错误 3 应输入 class、delegate、enum、interface 或 struct G:\visualstudio\shape\shape\Form1.cs 74 32 shape
错误 4 应输入 class、delegate、enum、interface 或 struct G:\visualstudio\shape\shape\Form1.cs 79 17 shape
错误 5 应输入 class、delegate、enum、interface 或 struct G:\visualstudio\shape\shape\Form1.cs 83 30 shape
错误 6 应输入类型、命名空间定义或文件尾 G:\visualstudio\shape\shape\Form1.cs 86 9 shape
请大家帮忙看看是哪里出了问题呢?