Commit f0d4ec10 authored by rawan's avatar rawan

step3

parent 007c03db
......@@ -2,12 +2,13 @@ package hacker;
public class DescendingHackerThread extends Thread {
private Vault vault;
private int attempts = 0;
public static final int MAX_PASSWORD = 9999;
public DescendingHackerThread(Vault vault) {
this.vault = vault;
//A function that changes the name of the thread only to make it easier to track it while running
this.setName(this.getClass().getSimpleName());
}
......@@ -16,9 +17,12 @@ public class DescendingHackerThread extends Thread {
for (int x = MAX_PASSWORD; x >= 0; x--) {
attempts++;
System.out.print("\r" + this.getName() + " try: " + attempts + " ");
System.out.println();
if (vault.isCorrectPassword(x)) {
System.out.println("success " + this.getName() + "the correct password " + x);
System.out.println();
System.out.println("success " + this.getName() + "the password is: " + x + " after " + attempts + " attemps");
System.exit(0);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment