Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package app;
- import java.io.File;
- import jxl.Cell;
- import jxl.CellType;
- import jxl.LabelCell;
- import jxl.Sheet;
- import jxl.Workbook;
- public class ModulKlimatyzacja {
- private static String[][] pomocniczaReguly;
- private static String[][] regulyKlimatyzacji;
- public static void main(String[] args) {
- zczytajReguly();
- rozpiszReguly();
- }
- public static void zczytajReguly() {
- try {
- //java.net.URL url = app.ModulKlimatyzacjaPodlewanie.class.getResource("reguly/klimatyzacjaPodlewanie.xls");
- // System.out.println(url.toString());
- //URI uri = url.toURI();
- // System.out.println(uri.toString());
- System.out.println("2");
- //File file = new File("klimatyzacja1.xlsx");
- //System.out.println(file.getAbsolutePath());
- File file = new File("klimatyzacja.xls");
- System.out.println("3");
- Workbook workbook = Workbook.getWorkbook(file);
- System.out.println("4");
- Sheet sheet = workbook.getSheet(0);
- sheet.getSettings().setProtected(false);
- System.out.println("2");
- for (int i = 0; i < 9; i++) {
- for (int j = 0; j < 2; j++) {
- System.out.print(i + "."+j);
- }
- }
- //System.out.print("\n");
- for (int i = 0; i < 9; i++) {
- for (int j = 0; j < 2; j++) {
- Cell cel = sheet.getCell(j, i + 1);
- if (cel.getType() == CellType.LABEL) {
- LabelCell lcel = (LabelCell) cel;
- System.out.print(lcel.getString());
- pomocniczaReguly[i][j] = lcel.getString();
- }
- }
- //System.out.print("\n");
- }
- workbook.close();
- } catch (Exception e) {
- System.out.println("gowno");
- }
- //System.out.println("3");
- rozpiszReguly();
- }
- /**
- * Metoda rozpisująca pobrane metody z pliku xls i rozdzielająca je reguły
- * podlewania i reguły klimatyzacji
- */
- public static void rozpiszReguly() {
- int x = 0, y = 0, z = 0;
- for (int i = 0; i < 9; i++) {
- switch (pomocniczaReguly[i][0]) {
- case "ekstremalnie niska": {
- x = 0;
- break;
- }
- case "bardzo niska": {
- x = 1;
- break;
- }
- case "niska": {
- x = 2;
- break;
- }
- case "troche niska": {
- x = 3;
- break;
- }
- case "optymalna": {
- x = 4;
- break;
- }
- case "troche wysoka": {
- x = 5;
- break;
- }
- case "wysoka": {
- x = 6;
- break;
- }
- case "bardzo wysoka": {
- x = 7;
- break;
- }
- case "ekstremalnie wysoka": {
- x = 8;
- break;
- }
- default: {
- System.err.println("Error + 25");
- break;
- }
- }
- switch (pomocniczaReguly[i][1]) {
- case "bardzo mocne grzanie":
- y = 0;
- break;
- case "mocne grzanie":
- y = 1;
- break;
- case "srednie grzanie":
- y = 2;
- break;
- case "slabe grzanie":
- y = 3;
- break;
- case "brak ingerenci":
- y = 4;
- break;
- case "slabe chłodzenie":
- y = 5;
- break;
- case "srednie chlodzenie":
- y = 6;
- break;
- case "mocne chlodzenie":
- y = 7;
- break;
- case "bardzo mocne chlodzenie":
- y = 8;
- break;
- default:
- System.err.println("Error" + pomocniczaReguly[i][0]);
- break;
- }
- regulyKlimatyzacji[x][y]= pomocniczaReguly[i][3];
- System.out.println(" jhj");
- //System.out.println(pomocniczaReguly[x][y]+" ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement