Question: Question 2 please 1. Create a C# class called Document a. with the following Properties: i. ii. iii. Name (string) NumberOfPages (int) Created On (DateTime):
Question 2 please
1. Create a C# class called Document a. with the following Properties: i. ii. iii. Name (string) NumberOfPages (int) Created On (DateTime): make this a readonly property. Note that Date Time is a struct in the namespace System b. Add a constructor to allow initialization of all the properties c. Add ToString Method (hint: override toString method of System.Object class) Then, write a Main method to test your class Document. a. Create document with name "Phone Numbers.txt" and 3 pages b. Create document2 with name "Report.docx" and 30 pages Demo how you cannot change the Created On property of each document C. object 2. Create a class Employee a) private and static field nextAvailableln (int): create a static constructor to initialize this field to a random number (hint: you can use System.Random class). You can assume that IDs are numbers between 1-9999. Since nextAvailableld is static, all the Employee objects will share this field. b) with properties FirstName (string) LastName (string), ID (int): make it read only to allow initializing only with a constructor and then no more. c) Add a constructor to allow setting properties FirstName and LastName. Hint: ID will be initialized to nextAvailableID (make sure to increment nextAvailableld by one) d) Add ToString Method to display the full name and ID of the employee Then, write a Main method to test your class Employee. a. Create four Employee objects with references e1, e2, and e3 by providing first and last name of each employee b. Display the full name and id of each employee - note that each employee will have an automatically generated ID by the class Employee. A sample output of your program the first time it runs could be as below. Ist Employee 15Alex Smith 5302 2nd Employee isMike Brown 5303 3rd Employee is Thomas Whitman 5304 Next time, the program runs, employees will be assigned different but again continuing IDs. 15t Employee 15Alex Smith 20513 2nd Employee isMike Brown 2054 3rd Employee is Thomas whitman 2055
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
