Arvutiteaduse instituut
  1. Kursused
  2. 2019/20 kevad
  3. Objektorienteeritud programmeerimine (Narva Kolledž) (LTAT.NR.003)
EN
Logi sisse

Objektorienteeritud programmeerimine (Narva Kolledž) 2019/20 kevad

  • Home
  • Materials
  • Grading
  • Java Glossary
  • Cheat sheet (S1-S6)
  • Source Example
  • Links
Chapter 13

Tasks (to be submitted by 4.05)

Task 1

Create a class called IDRegister. The class should contain List<String> which holds personal identification numbers and the method register which adds a personal identification number to the list if it is not there yet. In addition, the program has to implement index method that returns the index of a personal identification number in the list or -1 if the personal identification number is not registered. Use synchronization so that the registry list is protected against the race. Use the list as a monitor.

Create the client class to demonstrate the work of threads.

Task 2

Create several text files with a large number of numbers separated by spaces. Write a program that reads the numbers from the file and finds the sum of the numbers in each file. In the main class, create a queue into which you can add the calculated sums, and a queue in which the names of the files waiting to be processed are stored. In the main method, the names of all the files should be placed into the queue for the filenames and three threads should start their work. Each thread should take a file from the queue with the filenames, read the numbers in, find the sum of the numbers and put the sum to the queue with the results. Once the file has been processed, the thread has to attempt to take the next file from the queue and process it, etc. The main method should take and display as many numbers from the result queue as there are files.

Chapter 13
  • Arvutiteaduse instituut
  • Loodus- ja täppisteaduste valdkond
  • Tartu Ülikool
Tehniliste probleemide või küsimuste korral kirjuta:

Kursuse sisu ja korralduslike küsimustega pöörduge kursuse korraldajate poole.
Õppematerjalide varalised autoriõigused kuuluvad Tartu Ülikoolile. Õppematerjalide kasutamine on lubatud autoriõiguse seaduses ettenähtud teose vaba kasutamise eesmärkidel ja tingimustel. Õppematerjalide kasutamisel on kasutaja kohustatud viitama õppematerjalide autorile.
Õppematerjalide kasutamine muudel eesmärkidel on lubatud ainult Tartu Ülikooli eelneval kirjalikul nõusolekul.
Courses’i keskkonna kasutustingimused