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(); }
private static void rectangleTest() { Rectangle r = new Rectangle(2, 2) + new Rectangle(5, 1); d("Rectangle area: " + r.area()); Square s = new Square(3); d("Square area: " + s.area()); }
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) { Console.WriteLine("Enter the length"); Rectangle rectangle = new Rectangle(); long a, b; a = (long)Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Enter the width"); b = (long)Convert.ToDouble(Console.ReadLine()); rectangle.calculateArea( a, b); Console.ReadKey(); }
public Rectangle(Rectangle rectangle) : this(rectangle.UpperLeft, rectangle.lowerLeft) { }
static void Main(string[] args) { Caller c = new Caller(); Rectangle r = new Rectangle(10, 7); Triangle t = new Triangle(10, 5); c.CallArea(r); c.CallArea(t); Console.ReadKey(); }
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 bool Contains(Rectangle s, Rectangle t) { return s.幅 > t.幅 && s.高さ > t.高さ; }
static double GetArea(Rectangle x) { return x.幅 * x.高さ; }