Skip to content

Commit

Permalink
fixing reliability issues
Browse files Browse the repository at this point in the history
  • Loading branch information
DemeterAbelBence committed May 22, 2024
1 parent 225e90e commit ee169a5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/drukmakor/ObjectView.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ public int getKozepY() {
* @return View távolsága a ponttól
*/
public double getDistanceFromPoint(int px, int py) {
int dx = Math.abs(px - x);
int dy = Math.abs(py - y);
double dx = Math.abs(px - x);
double dy = Math.abs(py - y);
return Math.sqrt(dx * dx + dy * dy);
}

Expand Down
22 changes: 19 additions & 3 deletions src/main/java/org/drukmakor/ParancsErtelmezo.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,26 @@ public void runFromFile(String filename)
filename += ".txt";
}
ArrayList<String> parancsok = new ArrayList<String>();
BufferedReader br = null;
try {
//Beolvassuk a fájlt soronként
BufferedReader br = new BufferedReader(new FileReader(filename));
br = new BufferedReader(new FileReader(filename));
String line;
while ((line = br.readLine()) != null) {
parancsok.add(line);
}
} catch (IOException ioe) {
System.out.println("Hiba a fájl beolvasásakor! ("+ ioe + ")");
} finally {
// this block will be executed in every case, success or caught exception
if (br != null) {
// again, a resource is involved, so try-catch another time
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

parseAll(parancsok);
Expand All @@ -157,9 +168,9 @@ public void runFromUser()
try {
System.out.print("Kérem a parancsot: ");
String line;
br = new BufferedReader(new InputStreamReader(System.in));
while ((line = br.readLine()) != null) {
//Egyetlen parancsot tartalmazó arraylist (mivel a parse függvény arraylistet vár)
br = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> parancsok = new ArrayList<String>(List.of(line));
parseAll(parancsok);

Expand Down Expand Up @@ -1220,8 +1231,13 @@ private int levenshteinDistance(String s, String t) {
}
//A tömb végén lévő érték lesz a távolság
int l = dp.length;
int l0 = dp[0].length;
int l0;

if(l > 0)
l0 = dp[0].length;
else
return 0;

if(m >= 0 && m < l && n >= 0 && n < l0 )
return dp[m][n];
else
Expand Down

0 comments on commit ee169a5

Please sign in to comment.