Skip to content

Commit

Permalink
fix classes using checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
KarageorgiouMaria committed Dec 26, 2018
1 parent dc78940 commit 6655812
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 181 deletions.
Binary file modified ArrayListLine.class
Binary file not shown.
82 changes: 43 additions & 39 deletions ArrayListLine.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

Binary file modified Exceptions.class
Binary file not shown.
292 changes: 150 additions & 142 deletions Exceptions.java
Original file line number Diff line number Diff line change
@@ -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<ArrayListLine>[] 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<ArrayListLine>[] 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<ArrayListLine>[] 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<ArrayListLine>[] 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<ArrayListLine>[] 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<ArrayListLine>[] lists, int list) {
boolean exit=false;
if (lists[list].size() == 0) {
exit=true;
}
return exit;
}

//public int
}

0 comments on commit 6655812

Please sign in to comment.