0% found this document useful (0 votes)
5 views3 pages

CS411 Assignment 1 Solution File

This document outlines an assignment for CS411 - Visual Programming for Spring 2025, focusing on a Painting Management System implemented in C#. It includes a base class 'Shape' and three derived classes: 'Circle', 'Square', and 'Triangle', demonstrating polymorphism through method overriding. The program creates an array of shapes and displays their types using the overridden Display method.

Uploaded by

kainat amraish
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)
5 views3 pages

CS411 Assignment 1 Solution File

This document outlines an assignment for CS411 - Visual Programming for Spring 2025, focusing on a Painting Management System implemented in C#. It includes a base class 'Shape' and three derived classes: 'Circle', 'Square', and 'Triangle', demonstrating polymorphism through method overriding. The program creates an array of shapes and displays their types using the overridden Display method.

Uploaded by

kainat amraish
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/ 3

CS411 – Visual Programming

Assignment No. 01
Semester: Spring 2025
BC220400854

//Pate screenshot of output here

//Paste your code here

using System;

namespace PaintingManagementSystem
{
// Base class
class Shape
{
public virtual void Display()
{
Console.WriteLine("I am a generic shape.");
}
}
// Derived class: Circle
class Circle : Shape
{
public override void Display()
{
Console.WriteLine("I am a circle shape.");
}
}

// Derived class: Square


class Square : Shape
{
public override void Display()
{
Console.WriteLine("I am a square shape.");
}
}

// Derived class: Triangle


class Triangle : Shape
{
public override void Display()
{
Console.WriteLine("I am a triangle shape.");
}
}

class Program
{
static void Main(string[] args)
{
Console.WriteLine("My student Id is BC220400854\n");

// Creating an array of Shape references


Shape[] shapes = new Shape[4];
shapes[0] = new Shape(); // Base class object
shapes[1] = new Circle(); // Circle derived class object
shapes[2] = new Square(); // Square derived class object
shapes[3] = new Triangle(); // Triangle derived class object

// Demonstrating polymorphism
foreach (Shape shape in shapes)
{
shape.Display();
}
}
}
}

You might also like