Commit 55577373 authored by areej.mohammad's avatar areej.mohammad

step 4

parent 565e4667
...@@ -6,6 +6,7 @@ public class DescendingHackerThread extends HackerThread ...@@ -6,6 +6,7 @@ public class DescendingHackerThread extends HackerThread
super(vault,"Descending Hacker"); super(vault,"Descending Hacker");
} }
@Override @Override
//// Attempts to guess the password starting from 9999, decrementing down to 0
public void run(){ public void run(){
for(int guess=10000; guess>=0;guess --) for(int guess=10000; guess>=0;guess --)
{ {
......
...@@ -6,22 +6,25 @@ public class PoliceThread extends Thread{ ...@@ -6,22 +6,25 @@ public class PoliceThread extends Thread{
super("Police"); super("Police");
} }
@Override @Override
// Counts down from 10 seconds (time available before police arrive)
public void run(){ public void run(){
for(int i = 10; i>=0;i--) for(int i = 10; i>=0;i--)
if (i > 0) { if (i > 0) {
System.out.printf("Police arrive in %d seconds...\n", i); System.out.printf("Police arrive in %d seconds...\n", i);
} else { } else {
// عند الوصول إلى 0، تفوز الشرطة [cite: 23, 31]
System.out.println("\n**************************************************"); System.out.println("\n**************************************************");
System.out.println("Game over for you hackers! Police have arrived."); System.out.println("Game over for you hackers! Police have arrived.");
System.out.println("**************************************************"); System.out.println("**************************************************");
// يُنهي البرنامج بالكامل [cite: 23, 57] // Terminate the entire program
System.exit(0); System.exit(0);
} }
try{ try{
// Waits for one second (1000 milliseconds) for each count
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e){ } catch (InterruptedException e){
// If this thread is interrupted, it means a hacker won, so we stop the countdown
return; return;
} }
......
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