Khoá học lập trình C# (.NET Core) Bài tập ôn luyện OOP + Interface trong C# - Lập Trình C# - Lập Trình C Sharp
- 5.0/5.0
- 2k Đăng ký
- Học lập trình
- Tiếng việt
Thông tin khóa học
Question 1
I. Create an interface IPerson that has the following properties:
-
string Skills— Read/Write -
DateTime DateOfBirth— Read-only -
int Age— Read-only
II. Create an abstract class named Employee that performs the following tasks:
1. Fields – private
-
int _id— employee identity -
string _name— employee name
2. Constructor methods
-
First constructor:
Declare with one parameterint id, assign this value to the employee identity.
The employee name is assigned a default value:"No name". -
Second constructor:
Declare with two parametersint id, string name, then assign these values to the employee’s identity and name.
3. Properties – public
-
int ID— Read-only property that returns the employee ID. -
string Name— Read/Write property of the employee name.-
Must contain statements to throw a new
Exceptionif the input name’s length is less than 3 characters.
-
4. Abstract method – public
-
void ShowInfo()— without parameters.
III. Declaring class Programmer that inherits from abstract class Employee and implements interface IPerson.
1. Fields – private
-
string _skills— programmer skills -
DateTime _DOB— date of birth -
int _age— age of programmer
2. Constructor methods
-
First constructor with two parameters
(int id, string name)
→ Call base constructor with(id, name)and assign default values:-
_skills = string.Empty -
_DOB = DateTime.Now
-
-
Second constructor with three parameters
(int id, string name, string skills, DateTime dob)
→ Call base constructor(id, name), then assignskillsto_skillsanddobto_DOB.
3. Properties – public
-
string Skills— implement fromIPerson, Read/Write.
Must include statement to throw newExceptionif input value’s length < 0. -
DateTime DateOfBirth— implement fromIPerson, Read-only.
Returns the value of_DOB. -
int Age— implement fromIPerson, Read-only.
Returns the real age of the programmer calculated fromDateOfBirth.
4. Method – public
-
void ShowInfo()— display all programmer information in the following format:
Question 2
I. Create a class named HiredProgrammers that performs the following tasks:
1. Field – private
-
Declare a generic
List<Programmer>namedHPGM.
2. Constructor method
-
Declare a constructor with one parameter
int capacityto initialize theHPGMlist with the given capacity.
3. Methods – public
-
void AddNew(Programmer prog)
Add a programmer object into the listHPGM.
Must throw a newExceptionwhen the list is out of capacity. -
int ShowFilterInfo(int underage)
Display all information of programmers whoseAge≤underage.
Return the number of those programmers.
II. Create a class to test
-
Define an instance of
HiredProgrammersclass namedmyemployee, initialized with 3 as input capacity. -
Write statements to input 3 programmers and add them into
myemployee.
Usetry-catchblocks to handle exceptions during input. -
In the console:
-
Input a value
underage. -
Invoke
ShowFilterInfo(underage)withmyemployeeto display which programmers have an age less than or equal to that input value.
-
End of Question
Đăng nhập để làm bài kiểm tra
Chưa có kết quả nào trước đó
Chương trình
Nguyễn Văn An
Trần Thị Bích
Lê Hoàng Hải
Phạm Minh Tuấn
Đánh giá
B2. Đăng ký học
B3. Hoàn thành mua khoá học
B4. Thanh toán theo hướng dẫn
B5. Đợi chúng tôi kiểm tra thông tin và thêm bạn vào lớp học
Bước 1: Truy cập website https://gozic.vn/teacher/form
Bước 2: Điền thông tin theo yêu cầu. Để bản đăng ký được duyệt nhanh nhất, anh chị hãy điền đủ thông tin nhé.
Bước 3: Click vào "đăng ký ngay" để hoàn thành
Lưu ý:
Link video bài giảng mẫu: Video bài giảng mẫu là căn cứ để Trắc Nghiệm Việt duyệt về hình thức và chất lượng giảng dạy. Vì vậy anh chị hãy điền link này để đăng ký được duyệt nhanh nhất nhé.
Anh chị cũng nên mô tả kỹ về kinh nghiệm giảng dạy để Trắc Nghiệm Việt đánh giá nhé.
Chúc các anh chị và các bạn thành công, sớm gia nhập đội ngũ giảng viên Trắc Nghiệm Việt!
499,000 VNĐ
1,299,000 VNĐ
Tổng quan khóa học
- Bài học 67
- Thời gian Linh hoạt
- Mức độ Mới bắt đầu
- Ngôn ngữ Tiếng việt
- Chứng chỉ Không
Trần Văn Điệp
Founder tại QViet.vn