Click để truy cậpClick để truy cập

Đề Thi PE PRN212 - SU26 - PE - RE - NO4

adminadmin is verified member.

Well-known member
Thành viên BQT
Administrator
Moderating
Học kỳ
SU2026
Thời Gian
8/8/26
Loại tài liệu
PE
Mã Đề
PRN212_SU26_B1_PE_L2_211970
PRN212_SU26_B1_PE_L2_211970

PRN212 SU26 PE RE NO4 - Question 1 Instructions​

This document contains instructions and requirements for Question 1 of the PRN212 SU26 Practical Examination. It outlines the implementation of a Console Application for a library borrowing quota management system. Students must demonstrate concepts including inheritance, interface implementation, LINQ queries, exception handling, and delegates.

PRN212 SU26 PE RE NO4 - Question 1 Instructions​


INSTRUCTIONS

Please read the instructions carefully before doing the questions.
- You can use materials in your computer, notebook and text book.
- You are NOT allowed to use any device to share data with others.
Beside the above conditions, students must follow the following requirements:
1. The work must complete by using Visual Studio 2022++
2. The Framework must be .NET 8.0
3. THIS PART IS VERY IMPORTANT, PLEASE READ IT CAREFULLY AND FOLLOW THE INSTRUCTIONS.
- You are given a database script (.sql file) in Zip file. Execute the script before doing questions.
- You must use the given solution.
- You are not allowed to add any more libraries via NuGet Package Manager into the given solution.
- Just one of above requirements is violated, your work will be considered as invalid.
On completion, submit the whole solution folder.
Before submitting, you can delete the folder [bin] in each project to reduce the size of the solution to fit the requirements of PLA_Client.

QUESTION 1 (4 points).
You are required to create a Console Application that implements a library borrowing quota management system. Your application must demonstrate the following .NET concepts:
- Inheritance (Abstract class and subclass)
- Interface implementation
- LINQ queries on collections
- Exception Handling
- Delegate and callback function

IMPORTANT
- All code must be inside namespace Q1
- Use correct C# naming conventions (PascalCase for types, camelCase for variables)
- All classes, interfaces, and delegates must be public
- Implement ALL members exactly as specified (name, return type, parameters)

1. DELEGATE
Declare delegate LoanChangedCallback with the following signature:
void LoanChangedCallback(string memberName, int currentLoans);

2. INTERFACE
Create interface IBorrowable with the following members:
int CurrentLoans { get; } read-only property representing the current number of borrowed books
bool BorrowBooks(int quantity) - adds quantity to CurrentLoans. Validates quantity > 0; throws ArgumentException with message "Borrow quantity must be positive" if invalid. If CurrentLoans + quantity is greater than BorrowLimit, returns false. Otherwise, increases CurrentLoans and returns true.

3. CLASSES
Abstract Class MemberRecord
- Properties: string MemberCode { get; set; }, string FullName { get; set; }, int BorrowLimit { get; set; }, int CurrentLoans { get; set; }
- Constructor MemberRecord(string memberCode, string fullName, int borrowLimit, int currentLoans) initializes properties. Validates BorrowLimit > 0; throws ArgumentOutOfRangeException with message "BorrowLimit must be greater than 0" if invalid. Validates CurrentLoans >= 0 and CurrentLoans <= BorrowLimit; throws ArgumentOutOfRangeException with message "CurrentLoans must be between 0 and BorrowLimit" if invalid.
- Abstract method string GetMemberType() to be implemented by subclasses

Class StudentMember (extends MemberRecord, implements IBorrowable)
- Property: string Major { get; set; }
- Constructor StudentMember(string memberCode, string fullName, int borrowLimit, int currentLoans, string major) calls base constructor and sets Major
- Override string GetMemberType() - returns "Student"
- Implement bool BorrowBooks(int quantity) validates quantity > 0, throws ArgumentException with message "Borrow quantity must be positive" if invalid. If CurrentLoans + quantity > BorrowLimit, returns false. Otherwise, adds quantity to CurrentLoans and returns true.

Class LibraryManager
- Private field _members of type List<StudentMember>
- Private field _onLoanChanged of type LoanChangedCallback
- Constructor LibraryManager(LoanChangedCallback callback) - initializes empty list and stores the callback
- Method void AddMember(StudentMember item) - adds the item to the collection
- Method bool BorrowForMember(string memberCode, int quantity):
+ Finds the item with matching MemberCode
+ If not found, throws InvalidOperationException with message "Member not found: {memberCode}"
+ If found, calls item.BorrowBooks(quantity). If the operation was successful, invokes _onLoanChanged with (item.FullName, item.CurrentLoans). Returns the result of BorrowBooks()
- Method List<StudentMember> GetMembersWithAvailableQuota(int minQuota)
- uses LINQ to return members where BorrowLimit - CurrentLoans >= minQuota, ordered by available quota descending

4. TESTING (Main Method)
Write your own Main method that demonstrates all functionality:
- Create at least 3 StudentMember objects with different Major values
- Create a LibraryManager with a callback that prints to console
- Add all objects to the manager
 

Đính kèm

  • PRN212 SU26 PE RE NO4_001.webp
    PRN212 SU26 PE RE NO4_001.webp
    132.2 KB · Lượt xem: 23
  • PRN212 SU26 PE RE NO4_002.webp
    PRN212 SU26 PE RE NO4_002.webp
    76.5 KB · Lượt xem: 26
  • PRN212 SU26 PE RE NO4_003.webp
    PRN212 SU26 PE RE NO4_003.webp
    143 KB · Lượt xem: 23
  • PRN212 SU26 PE RE NO4_004.webp
    PRN212 SU26 PE RE NO4_004.webp
    128.7 KB · Lượt xem: 26
  • PRN212 SU26 PE RE NO4_005.webp
    PRN212 SU26 PE RE NO4_005.webp
    155.4 KB · Lượt xem: 25
  • PRN212 SU26 PE RE NO4_006.webp
    PRN212 SU26 PE RE NO4_006.webp
    97 KB · Lượt xem: 24
  • PRN212 SU26 PE RE NO4_007.webp
    PRN212 SU26 PE RE NO4_007.webp
    133.1 KB · Lượt xem: 23
  • PRN212 SU26 PE RE NO4_008.webp
    PRN212 SU26 PE RE NO4_008.webp
    69.8 KB · Lượt xem: 28
  • PRN212 SU26 PE RE NO4_009.webp
    PRN212 SU26 PE RE NO4_009.webp
    61.5 KB · Lượt xem: 21
  • PRN212 SU26 PE RE NO4_010.webp
    PRN212 SU26 PE RE NO4_010.webp
    45.4 KB · Lượt xem: 20
  • PRN212 SU26 PE RE NO4_011.webp
    PRN212 SU26 PE RE NO4_011.webp
    79.9 KB · Lượt xem: 17
  • PRN212 SU26 PE RE NO4_012.webp
    PRN212 SU26 PE RE NO4_012.webp
    121.6 KB · Lượt xem: 16
  • PRN212 SU26 PE RE NO4_013.webp
    PRN212 SU26 PE RE NO4_013.webp
    111.4 KB · Lượt xem: 20

Tạo tài khoản hoặc đăng nhập để bình luận

Bạn phải là thành viên mới có thể bình luận.

Tạo tài khoản

Hãy tạo tài khoản trên cộng đồng của chúng tôi. Thật dễ dàng!

Đăng nhập

Bạn đã có tài khoản? Đăng nhập tại đây.

X
Back
Top