0% found this document useful (0 votes)
23 views

Demo Code of Using This

This document defines a Rectangle class with private integer properties for x, y, width, and height. It includes three constructors - a default constructor that calls the second constructor with default values, a second constructor that initializes width and height, and a third constructor that initializes all four properties. Each constructor writes the property values to the console.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Demo Code of Using This

This document defines a Rectangle class with private integer properties for x, y, width, and height. It includes three constructors - a default constructor that calls the second constructor with default values, a second constructor that initializes width and height, and a third constructor that initializes all four properties. Each constructor writes the property values to the console.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

using System;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
rectangle r = new rectangle();
rectangle r1 = new rectangle(2, 3);
rectangle r2 = new rectangle(1, 4, 2, 3);
}
}
class rectangle
{
private int x, y, width, height;
public rectangle():this(0,0,0,0)
{
Console.Write("Con1: "+x);
Console.Write(y);
Console.Write(width);
Console.WriteLine(height);

}
public rectangle(int width, int height)
: this(0, 0, width, height)
{
Console.Write("Con 2: "+x);
Console.Write(y);
Console.Write(width);
Console.WriteLine(height);
}

public rectangle(int x, int y, int width, int height)


{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
Console.Write("Con 3:"+x);
Console.Write(y);
Console.Write(width);
Console.WriteLine(height);
}
}}

You might also like