Advertisement
niske

OOP Konstruktor

Nov 25th, 2024
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.FileReader;
  3. import java.io.IOException;
  4.  
  5. public class Poliklinika {
  6.  
  7. private Lekar[] lekari;
  8.  
  9. public Poliklinika(String fajl1, String fajl2) throws IOException {
  10. BufferedReader br = new BufferedReader(new FileReader(fajl1));
  11.  
  12. int brLekara = Integer.parseInt(br.readLine());
  13. lekari = new Lekar[brLekara];
  14.  
  15. for(int i = 0; i < brLekara; i++) {
  16. String ime = br.readLine();
  17. String prezime = br.readLine();
  18. String zanimanje = br.readLine();
  19. if(zanimanje.equals("pedijatar")) {
  20. lekari[i] = new Pedijatar(ime, prezime);
  21. }
  22. else {
  23. lekari[i] = new Pulmolog(ime, prezime);
  24. }
  25. }
  26.  
  27. br = new BufferedReader(new FileReader(fajl2));
  28. int brPacijenata = Integer.parseInt(br.readLine());
  29.  
  30. for(int i = 0; i < brPacijenata; i++) {
  31. String ime = br.readLine();
  32. String prezime = br.readLine();
  33. int brGodina = Integer.parseInt(br.readLine());
  34.  
  35. int randomBr = (int)(Math.random() * brLekara);
  36. Pacijent p = new Pacijent(ime, prezime, brGodina);
  37. lekari[randomBr].prihvati(p);
  38. }
  39. br.close();
  40. }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement