TP SFSD 2 En-2
TP SFSD 2 En-2
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.
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