Institute of Computer Science
  1. Courses
  2. 2019/20 spring
  3. Object-Oriented Programming (Narva College) (LTAT.NR.003)
ET
Log in

Object-Oriented Programming (Narva College) 2019/20 spring

  • Home
  • Materials
  • Grading
  • Java Glossary
  • Cheat sheet (S1-S6)
  • Source Example
  • Links
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
  • Institute of Computer Science
  • Faculty of Science and Technology
  • University of Tartu
In case of technical problems or questions write to:

Contact the course organizers with the organizational and course content questions.
The proprietary copyrights of educational materials belong to the University of Tartu. The use of educational materials is permitted for the purposes and under the conditions provided for in the copyright law for the free use of a work. When using educational materials, the user is obligated to give credit to the author of the educational materials.
The use of educational materials for other purposes is allowed only with the prior written consent of the University of Tartu.
Terms of use for the Courses environment