Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import java.util.ArrayList;
  2. // you can also use imports, for example:
  3. // import java.util.*;
  4.  
  5. // you can write to stdout for debugging purposes, e.g.
  6. // System.out.println("this is a debug message");
  7.  
  8. class Osoba
  9. {
  10. public int Wiek;
  11. public String Imie;
  12.  
  13. public Osoba(int wiek, String imie) {
  14. this.Wiek = wiek;
  15. this.Imie = imie;
  16. }
  17. }
  18.  
  19. class Solution {
  20.  
  21. public int solution(int X) {
  22.  
  23. ArrayList<Osoba> peopleList = new ArrayList<Osoba>();
  24.  
  25. for (int i = 0; i < X; i++) {
  26. int age = i*10>99 ? i*10%X : i*10;
  27. String name = "John " + ++i;
  28. peopleList.add(new Osoba(age, name));
  29. }
  30.  
  31. return countAdults(peopleList);
  32. }
  33.  
  34. public int countAdults(ArrayList<Osoba> peopleList) {
  35. int counter = 0;
  36.  
  37. for (Osoba osoba : peopleList) {
  38. if (osoba.Wiek > 18)
  39. counter++;
  40. }
  41. return counter;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement