Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. package app;
  2.  
  3. import java.io.File;
  4.  
  5.  
  6. import jxl.Cell;
  7. import jxl.CellType;
  8. import jxl.LabelCell;
  9. import jxl.Sheet;
  10. import jxl.Workbook;
  11.  
  12. public class ModulKlimatyzacja {
  13. private static String[][] pomocniczaReguly;
  14. private static String[][] regulyKlimatyzacji;
  15.  
  16. public static void main(String[] args) {
  17.  
  18. zczytajReguly();
  19. rozpiszReguly();
  20.  
  21. }
  22.  
  23. public static void zczytajReguly() {
  24. try {
  25. //java.net.URL url = app.ModulKlimatyzacjaPodlewanie.class.getResource("reguly/klimatyzacjaPodlewanie.xls");
  26. // System.out.println(url.toString());
  27. //URI uri = url.toURI();
  28. // System.out.println(uri.toString());
  29. System.out.println("2");
  30. //File file = new File("klimatyzacja1.xlsx");
  31. //System.out.println(file.getAbsolutePath());
  32. File file = new File("klimatyzacja.xls");
  33. System.out.println("3");
  34. Workbook workbook = Workbook.getWorkbook(file);
  35.  
  36. System.out.println("4");
  37. Sheet sheet = workbook.getSheet(0);
  38. sheet.getSettings().setProtected(false);
  39. System.out.println("2");
  40.  
  41. for (int i = 0; i < 9; i++) {
  42. for (int j = 0; j < 2; j++) {
  43.  
  44.  
  45. System.out.print(i + "."+j);
  46.  
  47.  
  48.  
  49. }
  50.  
  51. }
  52. //System.out.print("\n");
  53.  
  54.  
  55. for (int i = 0; i < 9; i++) {
  56. for (int j = 0; j < 2; j++) {
  57.  
  58. Cell cel = sheet.getCell(j, i + 1);
  59. if (cel.getType() == CellType.LABEL) {
  60. LabelCell lcel = (LabelCell) cel;
  61. System.out.print(lcel.getString());
  62. pomocniczaReguly[i][j] = lcel.getString();
  63.  
  64.  
  65. }
  66.  
  67. }
  68. //System.out.print("\n");
  69.  
  70. }
  71.  
  72.  
  73. workbook.close();
  74.  
  75. } catch (Exception e) {
  76. System.out.println("gowno");
  77. }
  78.  
  79. //System.out.println("3");
  80. rozpiszReguly();
  81.  
  82. }
  83.  
  84. /**
  85. * Metoda rozpisująca pobrane metody z pliku xls i rozdzielająca je reguły
  86. * podlewania i reguły klimatyzacji
  87. */
  88. public static void rozpiszReguly() {
  89. int x = 0, y = 0, z = 0;
  90.  
  91. for (int i = 0; i < 9; i++) {
  92.  
  93. switch (pomocniczaReguly[i][0]) {
  94. case "ekstremalnie niska": {
  95. x = 0;
  96. break;
  97. }
  98. case "bardzo niska": {
  99. x = 1;
  100. break;
  101. }
  102. case "niska": {
  103. x = 2;
  104. break;
  105. }
  106. case "troche niska": {
  107. x = 3;
  108. break;
  109. }
  110. case "optymalna": {
  111. x = 4;
  112. break;
  113. }
  114. case "troche wysoka": {
  115. x = 5;
  116. break;
  117. }
  118. case "wysoka": {
  119. x = 6;
  120. break;
  121. }
  122. case "bardzo wysoka": {
  123. x = 7;
  124. break;
  125. }
  126. case "ekstremalnie wysoka": {
  127. x = 8;
  128. break;
  129. }
  130. default: {
  131. System.err.println("Error + 25");
  132. break;
  133. }
  134. }
  135.  
  136. switch (pomocniczaReguly[i][1]) {
  137.  
  138. case "bardzo mocne grzanie":
  139. y = 0;
  140. break;
  141. case "mocne grzanie":
  142. y = 1;
  143. break;
  144. case "srednie grzanie":
  145. y = 2;
  146. break;
  147. case "slabe grzanie":
  148. y = 3;
  149. break;
  150. case "brak ingerenci":
  151. y = 4;
  152. break;
  153. case "slabe chłodzenie":
  154. y = 5;
  155. break;
  156. case "srednie chlodzenie":
  157. y = 6;
  158. break;
  159. case "mocne chlodzenie":
  160. y = 7;
  161. break;
  162. case "bardzo mocne chlodzenie":
  163. y = 8;
  164. break;
  165.  
  166.  
  167. default:
  168. System.err.println("Error" + pomocniczaReguly[i][0]);
  169. break;
  170. }
  171.  
  172.  
  173. regulyKlimatyzacji[x][y]= pomocniczaReguly[i][3];
  174. System.out.println(" jhj");
  175. //System.out.println(pomocniczaReguly[x][y]+" ");
  176.  
  177.  
  178. }
  179.  
  180. }
  181.  
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement