Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1.  
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.FileNotFoundException;
  5. import java.io.FileReader;
  6. import java.io.IOException;
  7. import java.util.ArrayList;
  8. import java.util.List;
  9.  
  10. public class Parser implements IParser{
  11.  
  12. static List <List<Integer>> dataSet = new ArrayList<>();
  13. static int amountOfTypes;
  14. static int amountOfWareHouses;
  15. static int amountOfOrders;
  16. static List<Integer> typeWeights = new ArrayList<>();
  17. static List<Drone> drones = new ArrayList<>();
  18. static Playarea playArea;
  19.  
  20. public static void main(String[] args) throws FileNotFoundException, IOException {
  21. System.out.println("ayylmao");
  22. readFile();
  23. for (int i = 0; i < dataSet.size(); i++) {
  24. if (i == 0) {
  25. for (int j = 0; j <= dataSet.get(i).get(2); j++) {
  26. drones.add(new Drone(dataSet.get(i).get(4)));
  27. }
  28. playArea = new Playarea(dataSet.get(i).get(0), dataSet.get(i).get(1),drones, dataSet.get(i).get(3), dataSet.get(i).get(4));
  29. }
  30. else if (i == 1) {
  31. amountOfTypes = dataSet.get(i).get(0);
  32. }
  33. else if (i == 2) {
  34. typeWeights = dataSet.get(i);
  35. }
  36. else if (i == 3) {
  37. amountOfWareHouses = dataSet.get(i).get(0);
  38. }
  39. else if (i == (amountOfWareHouses*2)+3) {
  40. amountOfOrders = dataSet.get(i).get(0);
  41. }
  42. else if(i > 3 & i <= (amountOfWareHouses*2)+3){
  43. if(i % 2 == 0){
  44. WareHouse wareHouse = new WareHouse(dataSet.get(i).get(0),dataSet.get(i).get(1),dataSet.get(i+1));
  45. }
  46. }
  47. else if(i > (amountOfWareHouses*2)+3){
  48. if(i % 2 == 1){
  49. Order order = new Order(dataSet.get(i).get(0),dataSet.get(i).get(1),dataSet.get(i+2));
  50. i+=2;
  51. }
  52.  
  53. }
  54.  
  55. System.out.println(amountOfOrders);
  56. System.out.println("KANAMUNA");
  57. }
  58. }
  59.  
  60. public static void readFile() throws FileNotFoundException, IOException {
  61.  
  62. try (BufferedReader br = new BufferedReader(new FileReader("busy_day.in"))) {
  63. String line;
  64.  
  65. while ((line = br.readLine()) != null) {
  66. List <Integer> lineInfo = new ArrayList<>();
  67. String[] newLine = line.split(" ");
  68. for(int i = 0;i< newLine.length;i++){
  69. int value = Integer.parseInt(newLine[i]);
  70. lineInfo.add(value);
  71. }
  72. dataSet.add(lineInfo);
  73. }
  74. // System.out.println(dataSet);
  75. }
  76. }
  77. // try (Stream<String> stream = Files.lines(Paths.get("busy_day.in"))) {
  78. //
  79. // stream.mapToInt(e -> e.split)forEach(e -> {
  80. // String[] newLine = e.split(" ");
  81. // newLine.map
  82. // });
  83.  
  84. @Override
  85. public Playarea getPlayarea() {
  86. // TODO Auto-generated method stub
  87. return playArea;
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement