Chapter 9 |
Tasks (to be submitted by 13.04)
Task 1. Modify example 1
Modify the first example as follows. If the user wants to copy a folder, the program outputs a message (e.g. You want to copy a folder) and finishes its work. If the user wants to copy a file, the program outputs the size of the file and the date when the file was modified.
Task 2
Create a class called Timetable
. One of the class constructors has to take in two arrays - String[] courses
and int[] begins
. The begins
array contains the time of the corresponding courses (Note: the time is converted into minutes, e.g. {10*60+15, 12*60+15}). The method int showBeginning(String course)
has to show the time when the course (given as an argument) begins.
The class should also have a method called writeIntoFile(String fileName)
which saves the courses and the times into the file using DataOutputStream
. Finally, add an alternative constructor which takes in only one argument - the file name and reads the data from the file into the arrays.
In the main class, demonstrate the use of the constructors and methods.
Hint: it is more convenient to read from the file if the number of course-time pairs is known in advance.
Task 3
Create a program which shows statistics on the given word in the given file. Solve the task using class BufferedReader
and method readLine
.
NB: it is not allowed to use class Scanner
.
Chapter 9 |