using System; using System.Collections.Generic; u 60
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespa...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication12
{
class Program
{
static void Main(string[] args)
{
Shape s = new Circle();
double area = s.GetArea();
double perimeter = s.GetPerimeter();
Console.WriteLine(area);
Console.WriteLine(perimeter);
s = new Circle(3);
area = s.GetArea();
perimeter = s.GetPerimeter();
Console.WriteLine(area);
Console.WriteLine(perimeter);
IComparable b = new Circle();
Console.WriteLine(b.disp(2,3));
}
}
interface Shape
{
double GetArea();
double GetPerimeter();
}
interface Icomparable
{
int disp(int r1,int r2);
}
class Circle : Shape, Icomparable
{
public int radius;
public Circle()
{
radius = 0;
}
public Circle(int radius)
{
this.radius = radius;
}
public double GetArea()
{
return Math.PI * Math.Pow(radius, 2);
}
public double GetPerimeter()
{
return Math.PI * radius * 2;
}
public int disp(int r1,int r2)
{
if(r1>r2)
return 1;
else if(r1<r2)
return -1;
else
return 0;
}
}
}
错误怎么改,图片有错误信息 展开
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication12
{
class Program
{
static void Main(string[] args)
{
Shape s = new Circle();
double area = s.GetArea();
double perimeter = s.GetPerimeter();
Console.WriteLine(area);
Console.WriteLine(perimeter);
s = new Circle(3);
area = s.GetArea();
perimeter = s.GetPerimeter();
Console.WriteLine(area);
Console.WriteLine(perimeter);
IComparable b = new Circle();
Console.WriteLine(b.disp(2,3));
}
}
interface Shape
{
double GetArea();
double GetPerimeter();
}
interface Icomparable
{
int disp(int r1,int r2);
}
class Circle : Shape, Icomparable
{
public int radius;
public Circle()
{
radius = 0;
}
public Circle(int radius)
{
this.radius = radius;
}
public double GetArea()
{
return Math.PI * Math.Pow(radius, 2);
}
public double GetPerimeter()
{
return Math.PI * radius * 2;
}
public int disp(int r1,int r2)
{
if(r1>r2)
return 1;
else if(r1<r2)
return -1;
else
return 0;
}
}
}
错误怎么改,图片有错误信息 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询