Multiple Inheritance Program using Interfaces in C#


Program

using System;

namespace AbstractClass_and_Interface
{
    class InterfaceExample
    {
        interface IPerson
        {
            void GetBasicInfo();
            void DisBasicInfo();
        }
        interface IEducation
        {
            void GetEducationDetails();
            void DisEducationDetails();
        }
        interface IEmployment
        {
            void GetEmploymentDetails();
            void DisEmploymentDetails();
        }
        class Report : IPersonIEducationIEmployment
        {
            string name;
            int age, salary;
            string degree;
            float percent;
            string compName, desig;

            public void GetBasicInfo()
            {
                Console.WriteLine("Enter Your Name:");
                name = Console.ReadLine();
                Console.WriteLine("Enter Your Age:");
                age = int.Parse(Console.ReadLine());
            }
            public void DisBasicInfo()
            {
            Console.WriteLine($"Your Name is {name} & Your Age is {age}");
            }
            public void GetEducationDetails()
            {
                Console.WriteLine("Enter Your Degree:");
                degree = Console.ReadLine();
                Console.WriteLine("Enter Your Percentage:");
                percent = float.Parse(Console.ReadLine());
            }
            public void DisEducationDetails()
            {
                Console.WriteLine($"Your degree is {degree} and your                                        percentage is {percent}");
            }
            public void GetEmploymentDetails()
            {
                Console.WriteLine("Enter Your Company Name:");
                compName = Console.ReadLine();
                Console.WriteLine("Enter Your Company Designation:");
                desig = Console.ReadLine();
                Console.WriteLine("Enter Your Salary:");
                salary = int.Parse(Console.ReadLine());
            }
            public void DisEmploymentDetails()
            {
                Console.WriteLine($"You are working in {compName} as                                             {desig} for salary {salary}");
            }
            public void GetAllDetails()
            {
                GetBasicInfo();
                GetEducationDetails();
                GetEmploymentDetails();
            }
            public void DisAllDetails()
            {
                DisBasicInfo();
                DisEducationDetails();
                DisEmploymentDetails();
            }
        }
        static void Main(string[] args)
        {
            Report rep = new Report();
            rep.GetAllDetails();
            rep.DisAllDetails();
            Console.ReadKey();
        }

    }//class

}//namespace

Output

Enter Your Name:
Nagaraj
Enter Your Age:
24
Enter Your Degree:
M.Sc App.Maths
Enter Your Percentage:
89
Enter Your Company Name:
HCL
Enter Your Company Designation:
System Analyst
Enter Your Salary:
40000
Your Name is Nagaraj & Your Age is 24
Your degree is M.Sc App.Maths and your percentage is 89
You are working in HCL as System Analyst for salary 40000


No comments:

Post a Comment