static void Main(string[] args) { Point centreRect = new Point(1, 1); Point centreSquare = new Point(0, 0); Rectangle rect = new Rectangle(3, 5, centreRect); Square square = new Square(2, centreSquare); Ellipse ellipse = new Ellipse(2, 1, centreSquare); Console.WriteLine(rect.ToString()); Console.WriteLine(rect.GetArea() + " " + rect.GetPerimeter()); Console.WriteLine(square.ToString()); Console.WriteLine(square.GetArea() + " " + square.GetPerimeter()); Console.WriteLine(ellipse.ToString()); Console.WriteLine(ellipse.GetArea() + " " + ellipse.GetPerimeter()); }
static void Main(string[] args) { Point p1 = new Point(1, 2); Point p2 = new Point(5, 1); Point p3 = new Point(3, 5); Point p4 = new Point(1, 5); Triangle triangle = new Triangle(p1, p2, p3); //Console.WriteLine(triangle.GetArea()); //Console.WriteLine(triangle.GetPerimeter()); Console.WriteLine(triangle.ToString()); Ellipse ellipse = new Ellipse(5, 10); //Console.WriteLine(ellipse.GetPerimeter()); //Console.WriteLine(ellipse.GetArea()); Console.WriteLine(ellipse.ToString()); Rectangle rectangle = new Rectangle(p1,p2,p3,p4); //Console.WriteLine(rectangle.Width); //Console.WriteLine(rectangle.Heigth); //Console.WriteLine(rectangle.GetArea()); //Console.WriteLine(rectangle.GetPerimeter()); Console.WriteLine(rectangle.ToString()); }
static void Main(string[] args) { Random random = new Random(); int rand = random.Next(1, 3); Drawer figure = new FigureDrawer(); figure.Draw(rand); Figure figure1 = new Circle(0, 0, 10); Console.WriteLine(figure1.ToString()); Figure figure2 = new Rectangle(0, 0, 0, 5, 5, 5, 0, 5); Console.WriteLine(figure2.ToString()); Figure figure3 = new Triangle(0, 0, 3, 3, 0, 6); Console.WriteLine(figure3.ToString()); Console.ReadKey(); }
static void Main(string[] args) { Point p1 = new Point(1, 2); Point p2 = new Point(5, 1); Point p3 = new Point(3, 5); Point p4 = new Point(1, 5); Triangle triangle = new Triangle(p1, p2, p3); //Console.WriteLine(triangle.GetArea()); //Console.WriteLine(triangle.GetPerimeter()); Console.WriteLine(triangle.ToString()); Ellipse ellipse = new Ellipse(5, 10); //Console.WriteLine(ellipse.GetPerimeter()); //Console.WriteLine(ellipse.GetArea()); Console.WriteLine(ellipse.ToString()); Rectangle rectangle = new Rectangle(p1, p2, p3, p4); //Console.WriteLine(rectangle.Width); //Console.WriteLine(rectangle.Heigth); //Console.WriteLine(rectangle.GetArea()); //Console.WriteLine(rectangle.GetPerimeter()); Console.WriteLine(rectangle.ToString()); }
private void button3_Click(object sender, EventArgs e) { richTextBox1.Text = Rec.ToString(); }
private void Draw_Click(object sender, EventArgs e) { // Rectangle if (this.radioButtonRectangle.Checked == true) { int x = Convert.ToInt32(this.textBoxX.Text); int y = Convert.ToInt32(this.textBoxY.Text); int height = Convert.ToInt32(this.textBoxHeight.Text); int width = Convert.ToInt32(this.textBoxWidth.Text); myRectangle = new Rectangle(x, y, height, width); // fill or draw? fill = false; //txt_Display String info = myRectangle.ToString(); this.textBoxDisplay.Text = info; this.textBoxDisplay.Visible = true; } // Square if (this.radioButtonSquare.Checked == true) { int x = Convert.ToInt32(this.textBoxX.Text); int y = Convert.ToInt32(this.textBoxY.Text); int width = Convert.ToInt32(this.textBoxWidth.Text); mySquare = new Square(x, y, width); // fill or draw? fill = false; //txt_Display String info = mySquare.ToString(); this.textBoxDisplay.Text = info; this.textBoxDisplay.Visible = true; } // Circle if (this.radioButtonCircle.Checked == true) { int x = Convert.ToInt32(this.textBoxX.Text); int y = Convert.ToInt32(this.textBoxY.Text); int width = Convert.ToInt32(this.textBoxWidth.Text); myCircle = new Circle(x, y, width); // fill or draw? fill = false; //txt_Display String info = myCircle.ToString(); this.textBoxDisplay.Text = info; this.textBoxDisplay.Visible = true; } // Ellipse if (this.radioButtonEllipse.Checked == true) { int x = Convert.ToInt32(this.textBoxX.Text); int y = Convert.ToInt32(this.textBoxY.Text); int height = Convert.ToInt32(this.textBoxHeight.Text); int width = Convert.ToInt32(this.textBoxWidth.Text); myEllipse = new Ellipse(x, y, height, width); // fill or draw? fill = false; //txt_Display String info = myEllipse.ToString(); this.textBoxDisplay.Text = info; this.textBoxDisplay.Visible = true; } this.panelDrawing.Invalidate(); // it causes the control to be redrawn this.panelDrawing.Update(); this.Refresh(); }