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

.NET PRactical 2

The document outlines an experiment on inheritance and interfaces in .NET technologies, featuring a code implementation of character classes such as Protagonist, MainCharacter, Antagonist, and their respective actions. The Main method demonstrates the creation of a Protagonist and a MainCharacter, showcasing their functionalities. The experiment is part of a course in the Faculty of Engineering and Technology, Department of Computer Engineering.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

.NET PRactical 2

The document outlines an experiment on inheritance and interfaces in .NET technologies, featuring a code implementation of character classes such as Protagonist, MainCharacter, Antagonist, and their respective actions. The Main method demonstrates the creation of a Protagonist and a MainCharacter, showcasing their functionalities. The experiment is part of a course in the Faculty of Engineering and Technology, Department of Computer Engineering.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

FACULTY OF ENGINEERING AND TECHNOLOGY

Department of Computer Engineering


01CE0523 - .NET Technologies

Experiment 2
AIM: Program on Inheritance and Interface

Source: Exp-2.cs

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practical2
{
class Character
{
public string name;
public int characterCode;
public string characterType;
}
class Protagonist : Character
{
public Protagonist()
{
this.characterType = "Favorite character in the Series";
}

public void ShowProtagonistAction()


{
Console.WriteLine("The Protagonist will be : " + this.characterType);
}
}

class MainCharacter : Protagonist


{
public MainCharacter(string cname, int cCode)
{
this.name = cname;
this.characterCode = cCode;
}
public void ShowMainCharacterAction()
{
ShowProtagonistAction();
Console.WriteLine("The name of the Character is: " + this.name);
Console.WriteLine("The Code of the Character is: " +
this.characterCode);
}
}
/*class SecondaryCharacter : Protagonist
{

GUY BRUNO NDIKUMANA(92200103297) BATCH: C |4


FACULTY OF ENGINEERING AND TECHNOLOGY
Department of Computer Engineering
01CE0523 - .NET Technologies

class Antagonist : Character


{

class MainAntagonist: Antagonist


{

}
class SecondaryAntagonist : Antagonist
{

}
*/

class Program
{
static void Main(string[] args)
{
Console.WriteLine("92200103297, Bruno");
Protagonist shanks = new Protagonist();
shanks.ShowProtagonistAction();
MainCharacter luffy = new MainCharacter("Monkey D. Luffy", 35);
luffy.ShowMainCharacterAction();
Console.ReadKey();
}
}
}

Output:

GUY BRUNO NDIKUMANA(92200103297) BATCH: C |5

You might also like