SOLVE IN "C#" Write a program to create a class employee, it consist of ID, name, department and address. All employees belongs to “Computer Science” department and it can never be changed by any means. Employee ID is initialized only once when Employee object is created, any further attempt to change ID should be failed. Class must have a 3 parameterized constructor to set values and two methods: print(): to display all the data of a particular employee totalObjects(): to count and print total number of objects that has been created In Main(), create atleast two objects of employee class, display their records by calling print() function and also print the total number of objects that has been created. Sample Main Method: static void Main(string[] args) { Employee obj1 = new Employee(1, "AMMAD", "Karachi"); obj1.print(); Employee obj2 = new Employee(2, "ALI", "Islamabad"); obj2.print(); Employee.totalObjects(); }
SOLVE IN "C#"
Write a program to create a class employee, it consist of ID, name, department and address. All employees belongs to “Computer Science” department and it can never be changed by any means. Employee ID is initialized only once when Employee object is created, any further attempt to change ID should be failed. Class must have a 3 parameterized constructor to set values and two methods:
- print(): to display all the data of a particular employee
- totalObjects(): to count and print total number of objects that has been created
In Main(), create atleast two objects of employee class, display their records by calling print() function and also print the total number of objects that has been created.
Sample Main Method:
static void Main(string[] args)
{
Employee obj1 = new Employee(1, "AMMAD", "Karachi");
obj1.print();
Employee obj2 = new Employee(2, "ALI", "Islamabad");
obj2.print();
Employee.totalObjects();
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images