Institute of Computer Science
  1. Courses
  2. 2017/18 spring
  3. Object-Oriented Programming (Narva College) (P2NC.01.083)
ET
Log in

Object-Oriented Programming (Narva College) 2017/18 spring

  • Home
  • Materials
  • Java Glossary
  • Source Example
  • Cheat sheet (S1-S6)
  • Grading
  • Links
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 
  • 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