CSE116A,B Introduction to CS II for Majors : LAB 3 Objectives: 1. Make a package of classes. 2. Using and REUSING a classes from a package. Problem Statement: In this lab we will create two useful classes for banking applications called BankUI and BankAccountRecord in a package named "bank". We will test this package by using it in an application that creates ineteractively new accounts and stores them in a sequential file. Then we will use the same package in another application CreditInquiry that simply lists all the accounts in credit, debit and zero balance categories. TO DO: 1. In your cse116/fall2000/lab directory (you should have one by now) create a new directory "bank". This directory will hold the two classes that go in the package. mkdir bank cp ~bina/cse116/fall2000/lab/bank/*.java . 2. Study the two programs. Open BankUI.java. Add a line package bank; after the comments at the beginning of the file. Save it. 3. Repeat the same for the other file: BankAccountRecord.java. 4. Compile: javac BankUI.java javac BankAccountRecord.java 5. Now change directory to the parent directory. cd .. 6. Create another directory named lab4. Change directory to lab4. mkdir lab4 cd lab4 7. Copy the first application CreateSequentialFile.java. cp ~bina/cse116/fall2000/lab/lab4/CreateSequentialFile.java . 8. Add a line that imports the classes from bank package. import bank.*; 9. Save it. Compile it. javac CreateSequentialFile.java 10. Observe the errors. What is happening? Explain. It is not able to fine "bank" package? How to solve this problem. One of the solutions is to add a classpath to where the pacakge is located. Next step shows how to do this. 11. Go to your home directory. cd 12. Edit your .cshrc file to include a CLASSPATH that includes the path of the directory where "bank" is located. This will be /u0/faculty/bina/cse116/fall2000/lab/ for me. You can find out about the path by typing in "pwd" after moving to the directory where "bank" is located. Add this to you CLASSPATH environment variable. Your TA may help with this. Or you can see my .cshrc file for example. After updating your CLASSPATH environment variable, you will have to source your .cshrc file. source .cshrc 13. Now you get back to your lab4 directory and compile. It should go fine. Execute your program using java CreateSequentialFile 14. When it asks for a file name using the "FileChooser" that appears on the screen, navigate to your lab4 directory and type in lab4Data as the name for the data file. 15. After entering 3 sets of data, one with positive balance, one with negative balance and one with 0 balance, close the application. 16. Now copy another application CreditInquiry from ~bina/cse116/fall2000/lab/lab4 to your lab4 directory. It uses the same package "bank". Compile it and run it. You will see the data you entered in the first application getting displayed by this application. 17. Close the application. 18. Run CreateSequentialFile application and CreditInquiry one after another in the background. You can see the update from one application getting displayed in the second application concurrently. java CreateSequentialFile & java CreditInquiry & 19. Close the applications after experimenting with their features. 20. Study the programs and understand the reusability of the classes in the pacakge "bank". Observe the this is not a robust program. (You may try out your exception handling skills from last lab.. thouugh it is not a required element of this lab..).