Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- // you can also use imports, for example:
- // import java.util.*;
- // you can write to stdout for debugging purposes, e.g.
- // System.out.println("this is a debug message");
- class Osoba
- {
- public int Wiek;
- public String Imie;
- public Osoba(int wiek, String imie) {
- this.Wiek = wiek;
- this.Imie = imie;
- }
- }
- class Solution {
- public int solution(int X) {
- ArrayList<Osoba> peopleList = new ArrayList<Osoba>();
- for (int i = 0; i < X; i++) {
- int age = i*10>99 ? i*10%X : i*10;
- String name = "John " + ++i;
- peopleList.add(new Osoba(age, name));
- }
- return countAdults(peopleList);
- }
- public int countAdults(ArrayList<Osoba> peopleList) {
- int counter = 0;
- for (Osoba osoba : peopleList) {
- if (osoba.Wiek > 18)
- counter++;
- }
- return counter;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement