Fred Bear

Fred Bear

DVD Rental system

 

Description

 

Create a new project in Visual studio with name made up as follows:

 

<initial><family name>Ass2

 

Thus I would create a project rdazeleyAss2.

 

Write an application in Visual studio to manage a simple DVD hire store (note: this is simply an exercise and is in not intended to accurately model a DVD stores operation exactly – for instance there is no money involved). This program simply records and outputs some details of DVDs, customers and staff. The program will be able to process the hiring of DVDs to customers by staff. The program consists of classes that you must author, plus a test class that you will use to test these classes. The classes you will need to create are Store, DVD, Person, Customer, GoldCardCustomer, and Staff, which are summarised below (minus the appropriate get and set methods, constructors, copy constructors and deconstructors, which you must supply). You will also need to create additional Exception classes.

 

Store

Store is a concrete class that maintains three vectors:

Instance Variables

  • A list of Staff            -     Maintains a list of Staff that work at a store.
  • A list of Customers   -     Maintains a list of Customers that are eligible to hire DVDs from a Store.
  • A list of DVDs                -     Maintains a list of DVDs that are available at a store.

 

Methods:

  • A method to add a DVD to the list of DVDs
  • A method to add a new Customer to the list of Customer’s
  • A method to add a new Staff Member to the list of Staff
  • A method to print a list of current DVDs and their details
  • A method to print a list of current Customer’s and their details
  • A method to print a list of Staff and their details
  • A method to print a list of DVDs that are currently overdue along with the Customer’s details
  • A method that takes a Staff member, a Customer and a list of DVDs and hires those DVDs to the Customer. This method should hire these DVDs to the Customer (providing there are no Exceptions) and increment the Staff member’s Customer count. Each DVD should also be assigned a due date.
  • A method that takes a Staff member, a Customer and a list of DVDs and returns those DVDs. This method should return these DVDs from a Customer and increment the Staff member’s Customer count.

 

Person

The Person class is an abstract class from which Staff, Customer and GoldCardCustomer classes descended.

 

Instance Variables

  • A String representing the person’s name
  • A String for the persons address
  • An integer representing the persons age

Staff

The Staff class is a concrete class that extends Person. Each Staff object maintains a count of how many Customers they have served.

 

Instance variables

  • A count of how many customers have been served by them.

Methods:

  • Increase the customer count by one.

 

Customer

The Customerclass is a concrete class that extends Person. A Customer can hire up to 5 DVDs at a time.

 

Instance variables

  • A list of DVDs currently hired

 

Methods

  • A function to hire DVDs. This method takes a list of DVDs to hire. If an error occurs during the hiring process an appropriate exception should be thrown, which should be handled by the calling method (Note, you will need to create additional Exception classes to handle this – you should have different exception types for each different error and should handle them separately in your calling method). Possible errors are:
    • More than the allowed number of DVDs are about to be hired to the Customer.
    • The DVD is already hired out.
    • The Customer’s age is too young for one (or more)  of the DVDs rating.

R must be 18 years or older

MA must be 15 years or older.

M, PG and G can legally hired by anyone.

  • A function to return DVDs from a Customer. This method takes a list of DVDs and removes them from the Customer’s list of DVDs.

GoldCardCustomer

The GoldCardCustomerclass is a concrete class that extends the Customer class. A GoldCardCustomercan hire up to 10 DVDs at a time and DVDs that are overdue do not appear on the overdue list.

 

DVD

The DVD class is a concrete class. This class records basic details about the DVD as well as who has currently hired it and when it is due to be returned.

 

Instance Variables

  • A String representing the title of the DVD.
  • A String representing its rating – R, MA, M, PG, or G
  • A number representing how many days it can be hired for.
  • A Boolean flag representing if it is currently hired out
  • The Customer that currently has it hired.
  • A date representing the day the DVD is due to be returned.

 

Methods

  • A method to hire out the DVD to a customer. This method takes a Customer to be recorded as the hirer, sets the hired flag and assigns a due date to the DVD.
  • A method to return a previously hired DVD. This should remove the Customer field and reset the hired flag and the due date.

 

Testing of the Classes

Note: for this task you should not use formal unit testing packages such as JUnit test. Instead you will just create a simple class and pass some data around to test your application.

 

  1. Author a Test class. Create a method to in which to perform your tests, which you should be invoked from the main method.
  2. The method should perform the following tasks:
    1. Create a Store instance
    2. Create a few Staff objects as per the table below. Assign these objects to the stores list of Staff.
    3. Create a few Customer objects as per the table below. Create the objects as Customer or GoldCardCustomer as appropriate. Both types of Customers should be added to the Store’s list of Customers.
    4. Create a number of DVD objects as per the table below. Assign these objects to the Store’s list of DVDs.
    5. Print out all the Customers and their details.
    6. Print out all DVDs and their details.
    7. Set up a Calendar object to an initial date.
    8. The first Staff member attempts to hire the first DVD to the last Customer (Should be invalid).
    9. The second Staff member hires the first 4 DVDs to the first Customer in the table (Should be valid).
    10. The third Staff member attempts to hire the next 2 DVDs to the first Customer (Should be invalid).
    11. The first Staff member hire the next 6 DVDs to the second Customer in the table (Should be valid).
    12. The first Staff member hires the last DVD to the third Customer (Should be valid).
    13. Add two days to the current date and print an overdue list.
    14. The second Staff member returns all DVDs for all Customers.
    15. Print out the details of all Staff

Note: All of the output should be printed neatly and have appropriate headings.

Staff

Name

Address

age

Ben Casey

10 Smith St

32

Hawkeye Pierce

100 John Rd

47

Doogie Howser

1000 Mary Avenue

22

Customers

Name

Address

age

Customer Type

Fred Bear

1 Jane St

29

Regular

Betty Davis

5 Jones Rd

37

Gold Card

Bella Plant

15 Kaye Avenue

15

Regular

Thomas Edison

25 Fred Lane

12

Regular

 

DVDs

Title

Rating

Days Hire

The Shawshank Redemption

MA

7

WALL·E

G

1

The Godfather

R

7

Back to the Future

PG

7

Pulp Fiction

R

7

Schindler’s List

MA

7

One Flew Over the Cuckoo’s Nest

M

7

Casablanca

PG

7

Raiders of the Lost Ark

M

7

Toy Story 3

G

1

The Piano

M

7

About the Author

Ted Nugent – Fred Bear

This entry was posted in Uncategorized and tagged , , , , , , , , , . Bookmark the permalink.

Comments are closed.