Q 1) Write an application that creates a class named Registration. The application would be used by the counselors
of an IT education center, while registering students. The registration data entry
is done differently for carrer registration and for modular registration. Your application
should have seperate class for the two categories of students. In case of modular registration. Your application
should have seperate class for two categories of students. In case of Modular registration, you need to record the student's prior
experience or knowledge.
Hint: Use delegate in the registration class while registering a student to call the appropriate methods.
Ans 1)
using System;
namespace DelegateApp
{
class DelegateExample
{
public abstract class Student{ }
public void Modular : Student
{
public void GetExperience()
{
string name;
string experience;
Console.WriteLine("Enter your name:")
name = Console.ReadLine();
Console.WriteLine("Enter the experience of the student in the year:");
experience = Console.ReadLine();
Console.WriteLine("\n{0} has {1} years experience", name, experience);
}
}
public class General : Student
{
public void Aptitute()
{
string name;
string marks;
Console.WriteLine("\nEnter your name: ");
name = Console.ReadLine();
Console.WriteLine("Enter the marks of the aptitude test:");
marks = Console.ReadLine();
Console.WriteLine("\n{0} has got {1} marks in the aptitude test", name, marks);
}
}
public class Registration
{
public delegate void RegistrationType();
public RegistrationType Register;
public void DoRegistration(RegistrationType R)
{
Register = R;
}
public void DoNextRegistration()
{
if(Register ! = null)
{
Register();
}
}
}
static void Main(string[] args)
{
string s;
Console.WriteLine("Enter the registration type(Carrer/Modular): ");
s = Console.ReadLine().ToUpper();
Registration Reg = new Registration();
Modular Mod = new Modular();
General Gen = new General();
if( s== "MODULAR")
{
Reg.DoRegistration(new Registratin.RegistrationType(Mod.GetExperience));
Reg.DoNextRegistration();
else if (s == "CAREER")
{
Reg.DoRegistration(new Registration.RegistrationType(Gen.Aptitute));
Reg.DoNextRegistration();
}
else
Console.WriteLine("Invalid registration type");
Console.ReadLine();
}
}}
of an IT education center, while registering students. The registration data entry
is done differently for carrer registration and for modular registration. Your application
should have seperate class for the two categories of students. In case of modular registration. Your application
should have seperate class for two categories of students. In case of Modular registration, you need to record the student's prior
experience or knowledge.
Hint: Use delegate in the registration class while registering a student to call the appropriate methods.
Ans 1)
using System;
namespace DelegateApp
{
class DelegateExample
{
public abstract class Student{ }
public void Modular : Student
{
public void GetExperience()
{
string name;
string experience;
Console.WriteLine("Enter your name:")
name = Console.ReadLine();
Console.WriteLine("Enter the experience of the student in the year:");
experience = Console.ReadLine();
Console.WriteLine("\n{0} has {1} years experience", name, experience);
}
}
public class General : Student
{
public void Aptitute()
{
string name;
string marks;
Console.WriteLine("\nEnter your name: ");
name = Console.ReadLine();
Console.WriteLine("Enter the marks of the aptitude test:");
marks = Console.ReadLine();
Console.WriteLine("\n{0} has got {1} marks in the aptitude test", name, marks);
}
}
public class Registration
{
public delegate void RegistrationType();
public RegistrationType Register;
public void DoRegistration(RegistrationType R)
{
Register = R;
}
public void DoNextRegistration()
{
if(Register ! = null)
{
Register();
}
}
}
static void Main(string[] args)
{
string s;
Console.WriteLine("Enter the registration type(Carrer/Modular): ");
s = Console.ReadLine().ToUpper();
Registration Reg = new Registration();
Modular Mod = new Modular();
General Gen = new General();
if( s== "MODULAR")
{
Reg.DoRegistration(new Registratin.RegistrationType(Mod.GetExperience));
Reg.DoNextRegistration();
else if (s == "CAREER")
{
Reg.DoRegistration(new Registration.RegistrationType(Gen.Aptitute));
Reg.DoNextRegistration();
}
else
Console.WriteLine("Invalid registration type");
Console.ReadLine();
}
}}