Commit e3fcabd2 authored by tammam.alsoleman's avatar tammam.alsoleman

Build_AscendingHacker_Class

parent ae92a071
public class AscendingHackerThread extends Thread {
private Vault vault;
public AscendingHackerThread(Vault vault) {
this.vault = vault; // Store the vault reference
this.setName("AscendingHacker"); // Give this thread a clear name
this.setPriority(Thread.MAX_PRIORITY); // Give high priority
}
@Override
public void run() {
System.out.println(this.getName() + " started hacking from 0 to 9999");
// Try every number from 0 to 9999
for (int guess = 0; guess < 10000; guess++) {
// Check if this guess is correct
if (vault.isCorrectPassword(guess)) {
System.out.println(this.getName() + " cracked the vault! Password: " + guess);
System.exit(0); // End the entire program
}
}
// If we get here, we didn't find the password
System.out.println(this.getName() + " finished but didn't find the password!");
}
}
\ No newline at end of file
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