CSD201_-_PE_-_03_3199.webp
fresh_air

CSD201_-_PE_-_03_3199.webp

Bài viết gốc: Chủ đề 'CSD201 - PE - 03'
in the requestQueue class.
The expected output used to test your code are as follows:
Data List: (001,0,10,200) (003,0,3,70) (004,0,4,100) (005,0,3,70) (VIP,0,10,80)
Request (1,100) (12,500) (4,50) (4,400)
b. f2(): 2.5 marks - Serve the first request in the requestQueue
To complete the requirement f2(), students need to perform three specific tasks: (1)espeimplement the deQueue() function of the requestQueue structure, (2) use the returned result of deQueue() to perform the rent() function, then (3) use these two functions to serve the first request in the body of f2() function.
The rent() function consists of two steps:
o First, search the best Room to rent. If found, proceed to step 2. The best Room is:
An empty Room
Size > the size in the request
Price <= the price in the request
If there are more than one Room satisfying these three conditions below,
you should choose the Room with lowest price.
If there are more than one Room satisfying these four conditions below, you should choose the last Room. For example: if Room 003, 005, and 007 satisfy four conditions below, the answer is Room 007.
o Second, if the best Room is found, perform the renting action: update the status in the dataList from 0 to 1.
The expected output used to test your code are as follows:
Data List: (001,0,10,200) (003,0,3,70) (004,0,4,100) (005,0,3,70) (VIP,0,10,80)
Request: (1,100) (12,500) (4,50) (4,400)
Data List: (001,0,10,200) (003,0,3,70) (004,0,4,100) (005,1,3,70) (VIP,0,10,80)
Request: (12,500) (4,50) (4,400)
Explaination:
o The request (1,100) will be removed from the requestQueue, and then this request will be processed.
o The request is for renting a Room for one person (size=1), with the available money being 100 (price=100).
o The system finds two suitable Rooms (empty (status=0), price <100, with the
lowest price being 70), which are 003 and 005.
o The system then choose Room 005 because it appears after Room 003 in the dataList. Finally, the status of this Room will be updated to status=1 to indicate that it is now used.
c. f3(): 2.5 marks - Serve all requests in the requestQueue
2
Zoom
+ 100%
Close
Chưa có bình luận nào.

Thông tin

Category
CSD201
Thêm bởi
fresh_air
Ngày thêm
Lượt xem
5,894
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
CSD201_-_PE_-_03_3199.webp
File size
524.6 KB
Dimensions
2560px x 1494px

Share this media

Back
Bên trên Bottom