Saturday, 11 May 2013

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 Career registration and for Modular registration. Your application should have separate class for the two categories of students. In case of Career registration, you need to record the student's marks of the aptitude test. 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.


using System;
namespace DelegateExample
{
class DelegateExample
{
public abstract class Student {  }
public class 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 years:");
experience=Console.ReadLine();
Console.WriteLine("\n{0} has {1} experience",name, experience);
}
}
public class General : student
{
public void Aptitute()
{
string name;
string marks;
Console.WriteLine("n\Enter 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(career/Modular):");
s=Console.ReadLine().ToUpper();
Registration Reg=new Registration();
Modular Mod=new Modular();
General Gen=new General();
if (s=="MODULAR")
{
Reg.DoRegistration (new Registration.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();
}
}
}

No comments:

Post a Comment