Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

using System;

interface Resizable
{
void ResizeWidth(int width);
void ResizeHeight(int height);
}
class Rectangle : Resizable
{
private int width;
private int height;
public Rectangle(int width, int height)
{
this.width = width;
this.height = height;
}
public void ResizeWidth(int width)
{
this.width = width;
}
public void ResizeHeight(int height)
{
this.height = height;
}
public void DisplayDimensions()
{
Console.WriteLine("Width: " + width + ", Height: " + height);
}
}
class Program
{
static void Main(string[] args)
{
Rectangle rectangle = new Rectangle(5, 10);
Console.WriteLine("Initial Dimensions:");
rectangle.DisplayDimensions();
rectangle.ResizeWidth(8);
rectangle.ResizeHeight(15);
Console.WriteLine("\nResized Dimensions:");
rectangle.DisplayDimensions();
}
}

You might also like