CS 110: Introduction to Computing with Java

Lab 8

Pre-Lab

Do the following tasks before coming to lab.  You will not be able to work on the lab if you have not already completed these tasks.

Read the description of the lab.  Notice that you will be writing a NewReleasePrice class with several methods. Write the name of the methods you need to implement in this class.

Lab

Introduction

In this lab, you will complete the implementation of a Movie Rental application that can be used by a video store to calculate and print a customer’s bill. The video store clerk tells the application which movies a customer rented and for how long. The application calculates the charges and frequent renter points, which depend on the type of movie and how long the movie is rented. There are three kinds of movies: Regular, Children’s and New Releases. Customer’s charges and frequent renter points are calculated according to the following table:

 Movie Type Charges Frequent Renter Points Regular `\$2.00 for the first 2 days rental plus \$1.50 each additional day.` 1 Children \$1.50 for the first 3 days rental plus \$1.50 each additional day. 1 New Release \$3.00 for each days rental If  days rented > 1 then 2 otherwise 1

Purpose

This lab gives you some experience working with the Class inheritance, polymorphism and abstract classes.

Activities

1.       Copy the project.  A nearly complete set of Java files for the video store application can be found in lab8.zip.  Extract these files to folder of your choosing on the student drive.  As usual, open Dr Java and create a new project including the Java files you just unzipped.

2.       Look at the code.  You will be writing a class NewReleasePrice class that extends Price class.  Look at the current sub-classes of Price class.  Discuss with your partner and TA what your class will need to do.

3.       Run the tests.  For your convenience, we have built TestCustomer class to help you know when you have completed your class successfully.  Run the tests now.

4.       Write the NewReleasePrice class.  Remember to keep running the unit tests until they succeed.  (Is your code necessarily correct when the unit tests succeed?).

5.       Add a case for NEW_RELEASE to the switch statement in the Movie class.

6.       Customer class.  Your sample output should look like what follows.

Sample Output

You should see the following when you run the Customer class :

Before you leave, have your TA check off that you completed the lab.  Make sure each person saves a copy of your work.

Lab Report

Write a document describing your experiences.   Your lab must be printed (not handwritten).

Answer the following questions related to what you did in this week’s lab.  You may complete the code on your own, but the TA must certify that most of your work was done in the lab.