Arvutiteaduse instituut
  1. Kursused
  2. 2017/18 kevad
  3. Objektorienteeritud programmeerimine (Narva Kolledž) (P2NC.01.083)
EN
Logi sisse

Objektorienteeritud programmeerimine (Narva Kolledž) 2017/18 kevad

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

Tasks (to be submitted by Sun 20.05 23:55) 1 point

Task 1.

Create a class called IDRegister. The class should contain List<String> which holds the personal identification numbers and the method register which adds a personal identification number to the list if it is not there yet. In addition, there should be the method index that returns the index of 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.

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.

Session 14 
  • 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