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

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

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 NO3​

This document contains instructions and requirements for a .NET 8.0 practical examination in PRN212. It details a console application project focusing on OOP concepts such as inheritance, interface implementation, exception handling, delegates, and LINQ queries within the Q1 namespace.

PRN212 SU26 PE RE NO3​


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 PEA_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 NO3_001.webp
    PRN212 SU26 PE RE NO3_001.webp
    132.2 KB · Lượt xem: 29
  • PRN212 SU26 PE RE NO3_002.webp
    PRN212 SU26 PE RE NO3_002.webp
    76.5 KB · Lượt xem: 28
  • PRN212 SU26 PE RE NO3_003.webp
    PRN212 SU26 PE RE NO3_003.webp
    143 KB · Lượt xem: 27
  • PRN212 SU26 PE RE NO3_004.webp
    PRN212 SU26 PE RE NO3_004.webp
    128.7 KB · Lượt xem: 27
  • PRN212 SU26 PE RE NO3_005.webp
    PRN212 SU26 PE RE NO3_005.webp
    155.4 KB · Lượt xem: 26
  • PRN212 SU26 PE RE NO3_006.webp
    PRN212 SU26 PE RE NO3_006.webp
    97 KB · Lượt xem: 23
  • PRN212 SU26 PE RE NO3_007.webp
    PRN212 SU26 PE RE NO3_007.webp
    133.1 KB · Lượt xem: 23
  • PRN212 SU26 PE RE NO3_008.webp
    PRN212 SU26 PE RE NO3_008.webp
    70.5 KB · Lượt xem: 22
  • PRN212 SU26 PE RE NO3_009.webp
    PRN212 SU26 PE RE NO3_009.webp
    62.2 KB · Lượt xem: 18
  • PRN212 SU26 PE RE NO3_010.webp
    PRN212 SU26 PE RE NO3_010.webp
    46.2 KB · Lượt xem: 19
  • PRN212 SU26 PE RE NO3_011.webp
    PRN212 SU26 PE RE NO3_011.webp
    80 KB · Lượt xem: 15
  • PRN212 SU26 PE RE NO3_012.webp
    PRN212 SU26 PE RE NO3_012.webp
    112 KB · Lượt xem: 14
  • PRN212 SU26 PE RE NO3_013.webp
    PRN212 SU26 PE RE NO3_013.webp
    125.3 KB · Lượt xem: 29

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