C# language 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.   [this question is continued on next page] Sample Main Method: static void Main(string[] args) {             Employee obj1 = new Employee(1, "Zubair", "Karachi");             obj1.print();             Employee obj2 = new Employee(2, "Nabeel", "Islamabad");             obj2.print();             Employee.totalObjects(); }     Sample Output: ID : 1 Name : Zubair Department : Computer Science Address : Karachi ************************* ID : 2 Name : Nabeel Department : Computer Science Address : Islamabad ************************* Total number of objects : 2

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 11RQ
icon
Related questions
Question

C# language
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.

 

[this question is continued on next page]

Sample Main Method:

static void Main(string[] args)

{

            Employee obj1 = new Employee(1, "Zubair", "Karachi");

            obj1.print();

            Employee obj2 = new Employee(2, "Nabeel", "Islamabad");

            obj2.print();

            Employee.totalObjects();

}

 

 

Sample Output:

ID : 1

Name : Zubair

Department : Computer Science

Address : Karachi

*************************

ID : 2

Name : Nabeel

Department : Computer Science

Address : Islamabad

*************************

Total number of objects : 2

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT