siva kumar

siva kumar

  • NA
  • 36
  • 8.2k

Pl Correct it one class,one interface in interface concept

Jun 9 2016 11:12 AM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Class_with_Interface
{
class Program
{
class Employee
{
int EmpId;
string EmpName;
int Sal;
public void EmployeeDetails()
{
Console.WriteLine("Enter Employee Details... Employee Id,Employee Name,Salary");
EmpId = Convert.ToInt32(Console.ReadLine());
EmpName = Console.ReadLine();
Sal = Convert.ToInt32(Console.ReadLine());
}
public void DisplayEmployeeDetails()
{
Console.WriteLine("Display Employee Details : ");
Console.WriteLine("Employee Id "+EmpId);
Console.WriteLine("Employee Name "+EmpName);
Console.WriteLine("Salary is "+Sal);
Console.ReadLine();
}
}
interface iEmployee
{
void AcceptDepartment();
void DisplayDepartment();
}
class DEmployee : Employee,iEmployee
{
int DeptId;
string DepartmentName;
string EmpName;
public void AcceptDepartment()
{
Console.WriteLine("Enter Department Details...DeptId,DeptName,EmpName");
DeptId = Convert.ToInt32(Console.ReadLine());
DepartmentName = Console.ReadLine();
EmpName = Console.ReadLine();
}
public void DisplayDepartment()
{
Console.WriteLine("Display Department : ");
Console.WriteLine("Dept Id"+DeptId);
Console.WriteLine("Dept Name" +DepartmentName);
Console.WriteLine("Employee Name" +EmpName);
Console.ReadLine();
}
}
interface MInterface :iEmployee
{
void AcceptStudent();
}
interface MInterface1:MInterface
{
void DisplayStudent();
}
class Sample : MInterface1
{
int sid;
string sname;
string sclass;
public void AcceptStudent()
{
Console.WriteLine("Enter Student Details..Sid,SName,SClass");
sid = Convert.ToInt32(Console.ReadLine());
sname = Console.ReadLine();
sclass = Console.ReadLine();
}
public void DisplayStudent()
{
Console.WriteLine("Display Student Details...");
Console.WriteLine("Student Id : " + sid);
Console.WriteLine("Student Name : " + sname);
Console.WriteLine("Student Class : " + sclass);
}
}
static void Main(string[] args)
{
Sample x = new Sample();
x.AcceptStudent();
x.DisplayStudent();
Console.ReadLine();
}
}
}

Answers (1)