CSCE 145 Lab Test 2

Section 5

This lab is to be done with NO COMMUNICATION with others. You MAY use your book, notes, class slides on Blackboard, APIs (Java and Robots), past labs, and past homework; basically any materials directly related to the class. Outside materials or help from others is not allowed. You must dropbox the .java files by the end of this lab period (see bottom of page).

Overview

You will create a simple program that models DVDs in a DVD player.

Program

You need to create 2 classes, DVD and DVDPlayer. DVD has 2 instance variables: (String) title, and (String) releaseDate. DVDPlayer holds exactly 3 DVD objects as instance variables. The DVDPlayer class has a method called public void showDVDPlayer( ) that prints out the DVDs of the DVDPlayer. EACH CLASS should have accessors and mutators for all instance variables and 2 constructors: one a default (no parameters) and the other accepts parameters for all variables.

Create a driver that interacts with a user via the console. The program should ask the user for the 3 DVDs, put them into a  new DVDPlayer object, then print the entire contents of the DVD player. You can assume the user will enter the information in exactly the same format (title, a comma, release date) as shown in the example below.

In order to use a 'comma' as the delimiter when reading in the Shoe information from the console, use the following piece of code to instantiate the Scanner object.
Scanner console = new Scanner(System.in).useDelimiter(",");
In the past we have used the Scanner class with the default 'space' delimiter. Using a 'comma' as the delimiter will result in console.next( ) returning the next sequence of characters until a 'comma' is encountered. This said, you might have to do multiple console.next( ) calls to get all the console input.

Example Output

Please enter movie 1:

Apocalypse Now, 1979

Please enter movie 2:

Big Momma's House, 2000

Please enter movie 3:

Batman Begins, 2005

The DVDs in the player are:

Apocalypse Now, 1979

Big Momma's House, 2000

Batman Begins, 2005

 

DROPBOX YOUR .java FILES BEFORE 3:55pm (end of lab)! Don't wait until the last minute!