蓝海岛中月 2022-12-07 18:05 采纳率: 100%
浏览 23
已结题

怎么将其改写为Windows窗体应用程序

img

img

img


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 抽象类_抽象方法_多态性的实现
{
public abstract class Shape
{
protected string name;
public Shape(string name)
{
this.name = name;
}
public abstract void Show();
public abstract double Area();
}
public class Rectangle : Shape
{
protected double weight;
protected double height;
public Rectangle(string name, double w, double h)
: base(name)
{
this.weight = w;
this.height = h;
}
public override void Show()
{
Console.WriteLine("Rectangle:{0},area:{1}", name, weight * height);
}
public override double Area()
{
return weight * height;
}
}
public class Circle : Shape
{
protected double radius;
public Circle(string name, double r)
: base(name)
{
this.radius = r;
}
public override void Show()
{
Console.WriteLine("Circle:{0},area:{1}", name, Math.PI * radius * radius);
}
public override double Area()
{
return Math.PI * radius * radius;
}
}
class Program
{
static void Main(string[] args)
{
Shape[] s = { new Rectangle("小矩形", 1.0, 2.0), new Circle("大圆", 3.5) };
foreach (Shape e in s)
{
e.Show();
}
Console.ReadKey();
}
}
}

  • 写回答

1条回答 默认 最新

  • 赵4老师 2022-12-08 09:04
    关注

    重新创建一个WinForm程序,把这个代码添加进去。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 6月3日
  • 已采纳回答 5月26日
  • 修改了问题 12月7日
  • 创建了问题 12月7日

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题