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

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 8PE
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,