Session 10 |
Tasks (to be submitted by Sun 22.04 23:55) 1 point
Task 1. Upgrade example 1
Upgrade the first example as follows. If the user wants to copy a folder, the program outputs a message 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 time into the file using DataOutputStream
. Finally, add an alternative constructor which takes in only one argument - the file name from where the data has to be read.
In the main class, demonstrate the use of 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 the class BufferedReader
and the method readLine
.
Hint: it is not allowed to use the class Scanner
.
Session 10 |