Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

Practical

Programming in C# Page 1 of 4
Question 1
I. Create an interface IStudent that has the following methods:
- double ScholarshipAmount(): calculate scholarship amount .
- void DisplayDetail(): display the information of Student.
II. Create a class Student inherits from interface IStudent.

1. Fields – Private:

• string _name: Name of student.


• int _age: Age of student.
• float _math: mark Math of student.
• float _english: mark English of student.
• float _philosophy: mark philosophy of student.
• float _average: average mark of student

2. Properties:
• string Name – Name of student: R/W. Length of Name from 6 to 40
characters.
• int Age – age of student: R/W. Value of Age from 10 to 100
• float Math – mark math of student: R/W. Value of Math from 0 to 10
• float English – mark English of student: R/W. Value of English from
0 to 10
• float Philosophy – mark philosophy of student: R/W. Value of
Philosophy from 0 to 10
• float Average –average mark of student: R
Average= ((Math+English+Philosophy)/3)

Note:
1. R/W: Read-write property.
2. R: Read property.

3. Methods:

- Method DisplayDetail() to display all information of the student .


- Method ScholarshipAmount():
checking if marks are greater than 5 then calculating scholarship amount
using arithmetic operators
o Average >= 9 -> Scholarship amount = 200000
o Average : [8, 9) -> Scholarship amount = 160000
o Average : [7-8) -> Scholarship amount = 120000
Else
Scholarship amount =0

III. Declaring class Student2009 inherits from Student.


1. Field:
o float plusMark - plus mark of student. Default value is
0.1.

Programming in C# Page 2 of 4
2. Methods:
- Override method DisplayDetail() to display information of student, and plus
mark.
- Override method ScholarshipAmount(), with average mark= average mark +
plus mark

IV. Create a class StudentTest to test classes: Define an instance of Student2009


class. Please demo by get all information from the keyboard, then display
information of this instance.

Question 2 : The program demonstrates the use of Constructor and Indexers.


I. Create class Person:

1. Fields – Private:

o string _IDCard: ID Card of Person.


o string _name: Name of Person.
o int _age: Age of Person.

2. Properties:

o string IDCard – ID Card of Person: ReadOnly.


o string Name – Name of Person: ReadOnly.
o int Age – Age of Person: ReadOnly

3. Create constructor with three parameters to initialize the ID Card, Name


and Age.

II. Create class PersonVietNam

1. Creating a private array of class Person.


2. Constructor with one parameter to initialise the length of the array.
3. Indexer to set and get the values of Persons in the array.
4. Create method call DisplayDetails() to display the values stored in the array

III. Create class PersonTest is user to test the PersonVietNam class.

1. Create 2 Person
2. Create 1 PersonVietNam, then assign these Person into the array via
Indexer
3. Invoking the DisplayDetails method to display the PersonVietNam
details.

Programming in C# Page 3 of 4
-----THE END-----

Programming in C# Page 4 of 4

You might also like