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(); }

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 6PE
icon
Related questions
Question

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();

}

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 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
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT