Вы находитесь на странице: 1из 3

C# OOP Assignments

A) Assignments on OOPs.
1. Create a class Person with following data members: (Validations are given in
parenthesis.) a. PersonID string. (Must be 5 in length and can be alpha numeric) b. PersonName string. ( Must accept Characters only) c. Age int. (Should be between 25 to 58). Now do the following: d. Use methods to enter values in this class. (E.g. GetInfo() to accept values and use functions to return the values from the class.) e. Design a Form which will contain 3 textboxes for the data members. f. Put 2 buttons on the form out of which first button will call the GetInfo() and second button will call functions which will display values back in textboxes. g. Create an array of object for the Person class and display each Person record using messagebox. 2. Use properties and rewrite the above class. Perform steps e, f and g. 3. Derive an Employee class from the above Person class with following data members: (Validations are given in parenthesis.) a. EmpNo string (Must be 5 in length and can be alphanumeric). b. CompanyName string (Only characters). c. Department string (Only Characters) d. Post string (Only Character.) e. Salary double. Following are Salary values as per the post: Post Salary (Rs.) Manager 50000 Asst. Manager 47000 Modular Leader 45000 Sr. S/W Engg. 42000 S/W Engg. 40000 Sr. Programmer 38000 Programmer 36000 Analyst 33000 Tester 42000 Tech. Writer 36000 Now do the following; f. Use properties to work wilt the above data members. g. Design a windows form for Employee class. Use 2 buttons out of which first button will accept values and second button will display values back. Remember Text Box for Salary will be disabled and Salary will be automatically generated depending upon the post entered. h. Create an Array of Employee Class and display all records in a Message Box. 4. Derive a SalaryCalc class from an Employee class with following datamembers: a. HRA double b. TA double

c. d. e. f. g.

DA double TDS double PPF double GROSS_Sal double NET_Sal double

Read Salary from the Employee table Calculate HRA, TA, and DA as per table below: (Use properties) Salary HRA % of TA % of Salary Salary 1-3000 3 4 3001-6000 4 5 6001-9000 5 6 9001-12000 8 9 Else 11 12 GROSS_Sal = Salary + HRA + TA + DA If GROSS_Sal is greater than 10000 then it is 5% of GROSS_Sal, if 10001 to 15000 then 7%, for greater than 15001 then 9% else zero. PPF is 8% of GROSS NET_Sal = GROSS_Sal (TDS + PPF) Now display the net salary in Words (E.g. if Net Sal is Rs. 1234, the in words it will be displayed as One Thousand Two Hundred Thirty Four). 5. Try the following: a. How to call protected member of base class in derived class? b. Can abstract class contain Private Virtual method? c. Can sealed class have protected method? DA % of Salary 5 6 7 10 13

d. Consider the class is derived from a base class and implementing an interface, now if the base class and the interface has same method with same signature, then will the program give error message or will it be compiled and run successfully? e. How to call same signetured methods from 2 interfaces, where these 2 interfaces are implemented by the same class?
f. Can we have 2 main() in a same class? g. If two methods in same class have same name and same no, type and order of parameters to it and the return type is changed then will these two methods are overloading each other. h. Can the derive class method which is shadowing a base class method be overloaded? i. Can the method in above case be private or protected or static? j. What happens if all methods of abstract class are not implemented in the derived class? k. Can the static method be called using delegate?

B) Custom Attributes
6. Create a Custom attribute application as given in the class room session. 7. Create a Dll which will have an attribute applied class. Use this class to apply attributes in the class in different assembly. Print all the attributes.

Вам также может понравиться