0% found this document useful (0 votes)
29 views

TP SFSD 2 En-2

Uploaded by

loubnakhettab47
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

TP SFSD 2 En-2

Uploaded by

loubnakhettab47
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

UMBB, Faculty of Sciences Computer Engineering, 2nd Year, 3rd Semester

Department of Computer Science Subject : SFSD

Lab Work No. 2


File organisation

Context
To manage the rental system of a video game store, you are tasked with
creating a program. The rental information for each game is stored in files as
data blocks. Each block can contain multiple rental records, and each rental
may vary in length depending on the number of games rented by a customer.
Efficient processing of this data is crucial for providing a smooth customer
experience.

Objective
Write a program in C language to extract and display rental information
from data block files. Additionally, add functions to save this information to
a file and load it from a file.
A rental record should include fields for the customer’s name, the game
title(s), rental date, return date, and rental price. A customer is represented
by their ID, first name, last name, and contact details.
1 t y p e d e f s t r u c t Customer {
2 i n t customerID ;
3 char firstName [ 5 0 ] ;
4 c h a r lastName [ 5 0 ] ;
5 char c o n t a c t I n f o [ 1 0 0 ] ;
6 } Customer ;
7
8 t y p e d e f s t r u c t Date {
9 i n t day ;
10 i n t month ;
11 i n t year ;
12 } Date ;
13
2

14 t y p e d e f s t r u c t Game {
15 char t i t l e [ 1 0 0 ] ;
16 float rentalPrice ;
17 } Game ;
18
19 t y p e d e f s t r u c t Re nt a l {
20 int rentalID ;
21 Customer c ;
22 Game game ;
23 Date r e n t a l D a t e ;
24 Date r e t u r n D a t e ;
25 } R e nt al ;

The rental management system uses a TOF approach for storing the records
in blocks, which are organized for efficient data retrieval.

Rental Management and Disk Storage


When managing a large number of game rentals, it is essential to store
this information efficiently on disk. Using a block-based data storage ap-
proach helps optimize data reading and writing. Instead of storing each ren-
tal separately on disk, we group them into blocks. Each block can contain
multiple rentals, and these blocks are organized to facilitate data search and
management.
When searching for a specific rental, we avoid scanning the entire disk.
Instead, a logical search is performed on the information loaded from the disk,
improving performance by reducing the number of read/write operations.
In your application, rentals and customers are organized using ordered
linked lists (OLL). Each block contains a set of rental records or customer
information, and these blocks are linked to form a logical structure for storing
the data.

Suggested Steps
1. Define the necessary data structures to represent a customer, a game,
and a rental block.
2. Create a function createCustomer that allows input of customer in-
formation and returns a structure representing this information.
3. Create a function createRental that allows input of rental informa-
tion, including game titles, rental and return dates, and calculates the
total rental price.
3

4. Propose a function searchRental that searches for a rental based on


its ID.
5. Display the information of each rental, including the customer’s name,
game titles, rental date, return date, and total price.
6. Add a function saveRental to save rental information to a file.
7. Add a function loadRental to load rental information from a file.
8. Test your program by saving rental data to a file, then reloading it to
ensure the data is correctly retrieved.

You might also like