Advertisement
Guest User

Main

a guest
Jul 15th, 2020
889
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.ArrayList;
  5. import java.util.LinkedList;
  6. import java.util.List;
  7.  
  8. public class Main {
  9.  
  10. public static void main(String[] args) throws IOException {
  11. BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  12.  
  13. List<Car> cars = new LinkedList<>();
  14.  
  15. int nummm = Integer.parseInt(bf.readLine());
  16. while (nummm-- > 0) {
  17. String[] inline = bf.readLine().split("\\s+");
  18. String model = inline[0];
  19. int engineSpeed = Integer.parseInt(inline[1]);
  20. int hp = Integer.parseInt(inline[2]);
  21. int cargoW = Integer.parseInt(inline[3]);
  22. String cargoType = inline[4];
  23.  
  24. ArrayList<Tyre> tyres = new ArrayList<>();
  25. Tyre tyre = new Tyre(Double.parseDouble(inline[5]), Integer.parseInt(inline[6]),
  26. Double.parseDouble(inline[7]), Integer.parseInt(inline[8]),
  27. Double.parseDouble(inline[9]), Integer.parseInt(inline[10]),
  28. Double.parseDouble(inline[11]), Integer.parseInt(inline[12]));
  29. tyres.add(tyre);
  30.  
  31.  
  32. Car car = new Car(model, engineSpeed, hp, cargoW, cargoType, tyres);
  33. cars.add(car);
  34. }
  35. String type = bf.readLine();
  36. if (type.equals("fragile")) {//TODO pressure <1
  37. List<String> model = new ArrayList<>();
  38. for (int j = 0; j < cars.size(); j++) {
  39.  
  40.  
  41.  
  42. if (cars.get(j).getTyres().get(0).getPressure1() < 1 || cars.get(j).getTyres().get(0).getPressure2() < 1
  43. || cars.get(j).getTyres().get(0).getPressure3() < 1 || cars.get(j).getTyres().get(0).getPressure4() < 1) {
  44. model.add(cars.get(j).getModel());
  45. }
  46.  
  47. }
  48. model.forEach(System.out::println);
  49. } else {//TODO hp >250
  50. cars.forEach(e -> {
  51. if (e.getHp() >= 250) {
  52. System.out.println(String.format("%s", e.getModel()));
  53. }
  54. });
  55. }
  56. }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement