public static void Test() { Shape s = new Rectangle { 幅 = 2, 高さ = 3 }; Shape t = new Circle { 半径 = 2 }; Console.WriteLine(s.Contains(t)); Console.WriteLine(t.Contains(s)); }
static void Main(string[] args) { Circle myCircle = new Circle(); myCircle.Radius = 5; Rectangle myRectangle = new Rectangle(); myRectangle.Height = 5; myRectangle.Width = 3; for (int i = 0; i < 10; i++) { Console.WriteLine("Rectangle is currently {0} x {1}. The perimeter is {2}", myRectangle.Width, myRectangle.Height, myRectangle.getPerimeter()); Console.WriteLine("Circle radius is currently {0}. The perimeter is {1}", myCircle.Radius, myCircle.getPerimeter()); myCircle.scale(myCircle); myRectangle.scale(myRectangle); } Console.ReadLine(); }
static void Main(string[] args) { Console.Write("Input radius: "); double rect = Convert.ToDouble(Console.ReadLine()); Circle a = new Circle(rect); Console.WriteLine("Square is: " + a.Square()); Console.WriteLine("Perimeter is: " + a.Perimeter()); Console.ReadKey(); return; }
public Circle ReturnObject(int x, int y, double R) { Circle NewCircle = new Circle(x, y, R); return NewCircle; }
public Circle ReturnObject() { Circle NewCircle = new Circle(x, y, R); return NewCircle; }
static bool Contains(Circle s, Circle t) { return s.半径 > t.半径; }
static bool Contains(Circle s, Rectangle t) { return s.半径 * s.半径 * 4 > t.幅 * t.幅 + t.高さ * t.高さ; }
static bool Contains(Rectangle s, Circle t) { return s.幅 * s.幅 + s.高さ * s.高さ > t.半径 * t.半径 * 4; }
static double GetArea(Circle x) { return Math.PI * x.半径 * x.半径; }