Lecture 20:  Nested Data Structures

Activity:

In today's lecture we saw how to create and use nested data structures.  Recall that the basic data structures are structs and arrays.  Today you have the opportunity to design your own data structures.

Scenario:  You work at a local video store that rents movies in the format of dvds and vhs video tapes.  Your manager, knowing that you have some programming experience, wants you to design a program to manage customer accounts, the dvd library, and the vhs movie library.  Up to this point, the video store keeps all records of customers on paper (an index card for each listing their account number, their name, their address, their telephone number, their current rentals, the the due dates of their videos).  When a customer rents one or more videos, the title, format, the rental price, and the due dates are written on their index card.  This is a small shop -- the store only has one copy of each movie per format, so when a video or dvd is returned they know exactly who rented the video.  Your manager wants you to design a program that will keep track of customer information and movie information.  In this activity, please design some data structures that you would use to keep track of appropriate information.  If you create a struct, please write the C code for the struct.  You do not need to write any functions -- just the data structures.  Try to incorporate nested data structures into your plan.  (Hint:  If you need some help, think of each vhs video or dvd being represented by a structure.)