From 6655812f2603237131b6002e50bd8fa13b91421d Mon Sep 17 00:00:00 2001 From: KarageorgiouMaria Date: Wed, 26 Dec 2018 17:05:43 +0200 Subject: [PATCH] fix classes using checkstyle --- ArrayListLine.class | Bin 1187 -> 1205 bytes ArrayListLine.java | 82 +++++++------ Exceptions.class | Bin 2275 -> 2901 bytes Exceptions.java | 292 +++++++++++++++++++++++--------------------- 4 files changed, 193 insertions(+), 181 deletions(-) diff --git a/ArrayListLine.class b/ArrayListLine.class index 85b45698099164a02fcfd8db0104fa5924bee902..dcd17265afeec19ef01a44af01631121922279b8 100644 GIT binary patch delta 272 zcmZ3?xs}uK)W2Q(7#J7~8En`Ym>3!KQc{Zb(~I;IOH-5dQ*w(-^plGct144c%Tjal z3sQ@U^(P8!RyOb0`59Ok z1Q<9O1SfxC@?;ffU}un+?8I!$*gCn4*+Y?ufgk8BDF!wmDaXLUAkV~?>Cd3w#wUV_~zP*R`#pXYM-bX;4gBY!FPwNAnI~v65P9?6@_h*;K{_4b^cH7}z zFBf(d`3ryRYhB;#)LQ+U^Ij(=8-}`VCy8)al29^-nJHqX!?oE^&*9ZHmkc?%Ge=f* zo-r0=n^F<4vq*ztNTRg5DXl#6g;ObtEw)9igbxBY;w#lR+~|Xy(2R=dKXitSG-cUU eNLZyHUScggM&;Q*;5ho5BxX-d2(2NBX8#wD$SE@b diff --git a/ArrayListLine.java b/ArrayListLine.java index 5ef4c91..65f5591 100644 --- a/ArrayListLine.java +++ b/ArrayListLine.java @@ -1,45 +1,49 @@ -/* ArrayListLine class - *that will be used as a whole different line in our database +package dds.gr.aueb.dmst.crazydevelopers; + +/** ArrayListLine class. + * *that will be used as a whole different line in our database */ -public class ArrayListLine { - private String[] line; - // theoretical columns of our data base - /* - * Constructor of our class - * - */ - public ArrayListLine(String[] line) { - this.line = line; - } +public class ArrayListLine { + private String[] line; + // theoretical columns of our data base - /* - * method that helps changing a specific column of our line - */ - public void changeColumn(int column, String x) { - line[column] = x; - } + /** + * Constructor of our class. + * + */ + public ArrayListLine(String[] line) { + this.line = line; + } - /* - * Method that prints specific Line, will be used in the class Functions - */ - public void printLine() { - System.out.print("|"); - for (int i = 0; i < line.length; i++) { - System.out.printf("%15s %5s|",line[i],""); - } - System.out.println("\t"); - } + /** + * method that helps changing a specific column of our line. + */ + public void changeColumn(int column, String x) { + line[column] = x; + } - /* - * Method that returns specific Line in an array, will be used in the class - * Functions - */ - public String[] getLine() { - String x[] = new String[line.length]; - for (int i = 0; i < line.length; i++) { - x[i] = line[i]; - } - return x; - } + /** + * Method that prints specific Line, will be used in the class Functions. + */ + public void printLine() { + System.out.print("|"); + for (int i = 0; i < line.length; i++) { + System.out.printf("%15s %5s|",line[i],""); + } + System.out.println("\t"); + } + + /** + * Method that returns specific Line in an array, will be used in the class. + * Functions + */ + public String[] getLine() { + String[] x = new String[line.length]; + for (int i = 0; i < line.length; i++) { + x[i] = line[i]; + } + return x; + } } + diff --git a/Exceptions.class b/Exceptions.class index 06112a14504aaa1580777ecc8c2310e2bcf69c3d..d22e247ce6edbda6bbfe3c29b40b3dd1a4d07bbc 100644 GIT binary patch literal 2901 zcmb`I?Nbw16vm&;Zn6*}2nq^@3Ticgn2Ji3msIfugCN!*zSho?tYIP$QJ59s&)JGIZf2}|sxYCD|_yL<0F_nhba&bgQ0|NP|{ zfZaH!!>6DpmC8rcPShxvGtpEw??#i3vAB>jubG+Lyy@hlM~g{w-nDXeUWcY&?VNGV zh-M5s9i5z+Gn1|Y%{7aBHI1(>C0xg{(}M~ELzZp1F$HR*YnrBqb15?j6?Gx#s8P@` zZrSF^LUzVjaZP!ejj+cg%64$X# zL8BC0aIH)p&7z^W8-W`m0QB!TgO5288a2RsDy5Z2PTgh`O zdUP-*T-SiD9Gr3%I*hbo*(7#QL1eY><(9aeGK-T{Rr@p4$VP6dE}rdG+|9Ht1>L3W zWEEfTmBcnx&v7s=X-rgK{VxRQFNio!=onjRM_FYLRS4sv#k9P&NcNgYmj#VnjF+S| z8KO|7^L{v&DP(QJ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3GCd(K>{b-p^@@FOl4 z^i?wF1RAUH)3ftt(h=BNyA1y3n<(TQb5WqqVkrhoWn-oLT>&g`(^zDIZ!g#1KMb-2 zm2{pfRRhoPPB@jo7I#w&dv2PAosmupTu`^oC3z)yH>&U|1;?wDvzASC@qz|;g$4h_ z&Q@oiXT^34MeM49_yL}E==;}EKdg?d6@QbH%|1>k9R1q9K_@Qh-6=GILYXdX4(O%l-PUfqlhi6~UkML9_ z$p;G91&w(HGle*&EOC*tJhXhN#FVfaTE(Y#R1s9w`$$Lun<${Ft|~dAwQ7_)($Vwe z0d#c@s?zaYxpRF5ni^X}Z$zsw;4t(8-{Refro`5Yw>lnjU(Gm!1UY$e4L7K@#Oqyh z0eU&wPZfQ%4$yXh-iN6FFm(-bCd}Uurf`HgMwlgnbBN+HhH-`CS;Vl6qs)7pnUCQn z#&Dbc&oSY0eG`EVXhJ+iM8}R%aZ(f|OC7K1=oCV55_LlS4sDF&H+!FXXcZ4>mc}j* z4-wq#E*JN1_9X5m9<|Q-Wx`g%T2Ng@CaA68)C*yIT3K5Xc1WE&xQ>Pg@R7Dh4HJB0 z#8aUhR_|z{mRE5l;^B&G#d|K`Mm{^I2yhb?k*NTlVetW{SrAh!iD_Ej;-yIt%vowV zN95;;`2xoAHsdcd!we>IiPm>GdxfL-Fb{({O=e9Zi#g=kUqZ@-8-%_Aj}U)gRMPVY zB__R$=~WlgYo#g{-ZCbqifLYAI{DI=`u>~I^Df2vWkBDS0gY3l1eBtrXBAiilqR4I z0ewVkj)3wMcajG*i0~&GhG?(xQ?BNsORu2oe&V7RdO01_t7Q(8$X`zR1p~*Kzz9hg`bi2phea#o< V8#gl_w5MngW!8I1d7m58^A|JQ%iaJ0 diff --git a/Exceptions.java b/Exceptions.java index e7a5aaf..33a3603 100644 --- a/Exceptions.java +++ b/Exceptions.java @@ -1,152 +1,160 @@ +package dds.gr.aueb.dmst.crazydevelopers; /* * Class that will be used to check whether an Exception is thrown or not - * to guarantee that the programm will end normally + * to guarantee that the program will end normally */ -import java.util.*; -public class Exceptions { - String x; +import java.util.ArrayList; +import java.util.InputMismatchException; +import java.util.Scanner; - /* - * Method that reads the choice of the user and checks to see if the value of - * the choice produces the InputMismatchException and ends when the value is - * valid and no Exception is thrown - */ - public int NotIntegerException() { - int choice = 0; - int exitcode = 0; - while (exitcode == 0) { // loops until InputMismatchException is not caught - try { - Scanner input = new Scanner(System.in); - System.out.println(x); - choice = input.nextInt(); - exitcode = 1; - } catch (InputMismatchException e) { - System.out.println("Wrong type!"); - exitcode = 0; - } - } - return choice; - } +public class Exceptions { + String text; + + /** + * Method that reads the choice of the user and checks to see if the value of. + * the choice produces the InputMismatchException and ends when the value is + * valid and no Exception is thrown + */ + public int notIntegerException() { + int choice = 0; + int exitcode = 0; + while (exitcode == 0) { // loops until InputMismatchException is not caught + try { + @SuppressWarnings("resource") + Scanner input = new Scanner(System.in); + System.out.println(text); + choice = input.nextInt(); + exitcode = 1; + } catch (InputMismatchException e) { + System.out.println("Wrong type!"); + exitcode = 0; + } + } + return choice; + } - // Method that it initializes the variable x - public void display(String x) { - this.x = x; - } + // Method that it initializes the variable x + public void display(String x) { + text = x; + } - /* - * Method that checks if the value that the user gives throws the - * InputMismatchException or the ArrayOutOfBoundsException and ends when none of - * the above Exceptions are thrown - */ - public int OutOfBoundsException(ArrayList[] lists, int x1) { - int exitcode = 0; - int i = 0; - while (exitcode == 0) {// loops until none Exception is thrown - try { - i++; - if (i != 1) {// not entering the first time - try {// happens only if the argument throws ArrayIndexOutBoundsException - System.out.println("Try again!"); - System.out.println(x); - Scanner input = new Scanner(System.in); - x1 = input.nextInt(); - if (x1 <= lists.length &x1>0) { - exitcode = 1; - } - } catch (InputMismatchException e) { - System.out.println("Wrong type!"); - exitcode = 0; - } - } else if (x1 <= lists.length &x1>0) {// checks the argument of the method - exitcode = 1; - } - } catch (ArrayIndexOutOfBoundsException e) { - exitcode = 0; - } - } - return x1; - } + /** + * Method that checks if the value that the user gives throws the. + * InputMismatchException or the ArrayOutOfBoundsException and ends when none of + * the above Exceptions are thrown + */ + public int outOfBoundsException(ArrayList[] lists, int x1) { + int exitcode = 0; + int i = 0; + while (exitcode == 0) { // loops until none Exception is thrown + try { + i++; + if (i != 1) { // not entering the first time + try { // happens only if the argument throws ArrayIndexOutBoundsException + System.out.println("Try again!"); + System.out.println(text); + @SuppressWarnings("resource") + Scanner input = new Scanner(System.in); + x1 = input.nextInt(); + if (x1 <= lists.length & x1 > 0) { + exitcode = 1; + } + } catch (InputMismatchException e) { + System.out.println("Wrong type!"); + exitcode = 0; + } + } else if (x1 <= lists.length & x1 > 0) { // checks the argument of the method + exitcode = 1; + } + } catch (ArrayIndexOutOfBoundsException e) { + exitcode = 0; + } + } + return x1; + } - /* - * Method used for the same reason but with one more argument because we need to - * get to second dimension of the array lists - */ - public int OutOfBoundsException(ArrayList[] lists, int x1, int list) { - int exitcode = 0; - int i = 0; - while (exitcode == 0) { - try { - if (i != 0) { - try { - System.out.println("Try again!"); - System.out.println(x); - Scanner input = new Scanner(System.in); - x1 = input.nextInt(); - if (x1 <= lists[list - 1].size() &&x1>0) { - exitcode = 1; - } - } catch (InputMismatchException e) { - System.out.println("Wrong type!"); - exitcode = 0; - } - } - i++; - if (x1 <= lists[list - 1].size() &&x1>0) { - exitcode = 1; - } - } catch (ArrayIndexOutOfBoundsException e) { - exitcode = 0; - } - } - return x1; - } + /** + * Method used for the same reason but with one more argument because we need to. + * get to second dimension of the array lists + */ + public int outOfBoundsException(ArrayList[] lists, int x1, int list) { + int exitcode = 0; + int i = 0; + while (exitcode == 0) { + try { + if (i != 0) { + try { + System.out.println("Try again!"); + System.out.println(text); + @SuppressWarnings("resource") + Scanner input = new Scanner(System.in); + x1 = input.nextInt(); + if (x1 <= lists[list - 1].size() && x1 > 0) { + exitcode = 1; + } + } catch (InputMismatchException e) { + System.out.println("Wrong type!"); + exitcode = 0; + } + } + i++; + if (x1 <= lists[list - 1].size() && x1 > 0) { + exitcode = 1; + } + } catch (ArrayIndexOutOfBoundsException e) { + exitcode = 0; + } + } + return x1; + } + + /** + * Method used for the same reason but with different arguments because we need. + * to use the features for every list + */ + public int outOfBoundsException(int[] arrayNumberColumns, int x1, int list) { + int exitcode = 0; + int i = 0; + while (exitcode == 0) { + try { + if (i != 0) { + try { + System.out.println("Try again!"); + System.out.println(text); + @SuppressWarnings("resource") + Scanner input = new Scanner(System.in); + x1 = input.nextInt(); + if (x1 <= arrayNumberColumns[list - 1] && x1 > 0) { + exitcode = 1; + } + } catch (InputMismatchException e) { + System.out.println("Wrong type!"); + exitcode = 0; + } + } + i++; + if (x1 <= arrayNumberColumns[list - 1] && x1 > 0) { + exitcode = 1; + } + } catch (ArrayIndexOutOfBoundsException e) { + exitcode = 0; + } + } + return x1; + } + + /** + * Method used to check if there is data to a specific table. + * If there is no data in the DataBase return true otherwise false + */ + public boolean noDataBaseException(ArrayList[] lists, int list) { + boolean exit = false; + if (lists[list].size() == 0) { + exit = true; + } + return exit; + } +} - /* - * Method used for the same reason but with different arguments because we need - * to use the features for every list - */ - public int OutOfBoundsException(int[] arrayNumberColumns, int x1, int list) { - int exitcode = 0; - int i = 0; - while (exitcode == 0) { - try { - if (i != 0) { - try { - System.out.println("Try again!"); - System.out.println(x); - Scanner input = new Scanner(System.in); - x1 = input.nextInt(); - if (x1 <= arrayNumberColumns[list - 1]&&x1>0) { - exitcode = 1; - } - } catch (InputMismatchException e) { - System.out.println("Wrong type!"); - exitcode = 0; - } - } - i++; - if (x1 <= arrayNumberColumns[list - 1]&&x1>0) { - exitcode = 1; - } - } catch (ArrayIndexOutOfBoundsException e) { - exitcode = 0; - } - } - return x1; - } - /* - * Method used to check if there is data to a specific table - * If there is no data in the DataBase return true otherwise false - */ - public boolean NoDataBaseException(ArrayList[] lists, int list) { - boolean exit=false; - if (lists[list].size() == 0) { - exit=true; - } - return exit; - } - - //public int -} \ No newline at end of file