Programs Referenced in Lecture 9

 

(1) Tunes.java from Java Software Solutions by Lewis & Loftus

Tunes.java

note Tunes.java contains both the test program Tunes and the class CD_Collection on the same file.

You compile it  as javac Tunes.java. This will create two class files   Tunes.class and  CD_collection.class

You run the Tunes class java Tunes

(2) Lotto programs

There are two versions.

(1)  The first which is  the version  in the notes prints out 6 lotto numbers. This is in the file

ChooseLotto1.java which contains both the   class Lotto1 and the program to run it  (ChooseLotto1)

when compiled (javac ChooseLotto1.java)  you will get two class files. The lotto1 class has an array of a fixed size 6.

 

(2) In the second version  the using  program is expanded  to include a loop which allows the user to specify the number of panels and  for each panel the number  of  numbers. In this version the class Lotto.class  gets the size of the array in the constructor.  

Lotto.java 

ChooseLotto.java

(3) Program to illustrate the contents of  reference variable

Employee.java

TestEmployee.java

(4) Program to illustrate passing a reference variable to a method

Use this with the class BankAccount from lecture 8

UseAccounts2.java

 

(5) Program to illustrate co-operating objects

    RunBank.java  This file contains the Docket class  and the using program RunBank.java  You will also need the file BankAccount.java to be in the same directory. The program RunBank.java instantiates BankAccount objects and docket objects.