Presentation is loading. Please wait.

Presentation is loading. Please wait.

Algorithm Programming 1 89-210 Exercise 4 Bar-Ilan University 2006-2007 תשס"ז by Moshe Fresko.

Similar presentations


Presentation on theme: "Algorithm Programming 1 89-210 Exercise 4 Bar-Ilan University 2006-2007 תשס"ז by Moshe Fresko."— Presentation transcript:

1 Algorithm Programming 1 89-210 Exercise 4 Bar-Ilan University 2006-2007 תשס"ז by Moshe Fresko

2 Exercise 4 List of Files in a Directory with their Sizes after Compressions  Goal : To write an application that will get a directory name and will display in a table GUI component the list of files in that directory, their original size, and their size after compression according to the best- compressing algorithm among a number of algorithms we have.  Constraints : You don ’ t have to run and create the real compressed files. Please note that even temporary files are not needed. Use ThreadPool to run the Algorithms for calculating the compressed length.  Command Line Parameters : The only Command line parameter will be the directory name. java Ex4 “ c:/mydir/ ”  You have to have the following files already implemented under the same directory. If you don ’ t have you can download from the course ’ s site. Compress.javathat includes the Compress interface LZW.javaLZ78.javaIdentity.java ThreadPool.javaJob.java

3 Exercise 4  GUI : Implement the view in a JTable component of Swing. 1. Create a JTable structure with your new TableModel. 2. The columns will be a. FileName b. Last Modification Date c. Size In MBytes if its size> 1MB, otherwise in KBytes if its size>1KB, otherwise in Bytes d. The best algorithm for Compression for that file. ( “ LZW ”, or ” LZ78 ”,etc.) e. Its size after applying that Compression This size as well will be displayed according to c.Size format. 3. Better to inherit from AbstractTableModel and redefine the following methods a. The Constructor(s) b. getRowCount c. getColumnCount d. getColumnName e. getValueAt  It will update the table as it will calculate the lengths for the Compression Algorithms.  When the window is closed, the thread pool will be stopped. The process must exit immediately.

4  The list of possible algorithms will be kept in an internal array of type Compression[].  The creation of Algorithms will be done with the Reflection Mechanism.  You can use simply: Class.forName(String) static function Class.newInstance() member function And a necessary casting Exercise 4

5 Example run

6 Exercise 3 Thread-Pool  Important: You submit via submitex.  Course number: 89-210  Exercise: ex4  Deliver all the necessary files. It must compile/work under Java 1.4/1.5. You can try it on the Unix environment (on Sunshine). Do not write debugging information to the console or any other place. Write enough comments. Write wherever you think there is a need for the understanding of the code. Write your code according to the OOP principles. Everybody must do it alone.  Deadline: 18 Jan 2007


Download ppt "Algorithm Programming 1 89-210 Exercise 4 Bar-Ilan University 2006-2007 תשס"ז by Moshe Fresko."

Similar presentations


Ads by Google