The world is about to end, but maybe, just maybe there is some Hope. So it give it a spin and try it. After all the fate of Earth rests in your hands!
(The code is well commented, I think you'll find everything you need out there.)
package com.test;
import java.util.ArrayList;
import java.util.List;
/*This class had been set to trigger on December 21, 2012.
*Due to a programming this class will trigger off in the next 15 mins
*of you reading it.
*Yes its a know issue and we've sorry about it, but right now there are other major
*issues to solve and this can wait for later!
**/
public class DoomsDayEarth
{
/*No point in returning anything once the world has been destroyed!*/
public static void destroyWorld(List<EvilObject> evilObjects)
{
/*You do get a chance to save the world. Try it!*/
Hope.save(evilObjects);
/*This code destroys the world and prints world destroyed.
*Prevent that from happening and if possible get it to print world saved
* */
for(Destroy d : evilObjects)
{
d.destroy();
}
}
public static void main(String[] args) {
List<EvilObject> evil = new ArrayList<EvilObject>();
evil.add(new EvilObject());
DoomsDayEarth.destroyWorld(evil);
}
}
/*This is the only class that you can modify. Whatever happens there is always Hope!*/
class Hope
{
/*Write some code here that will save the world. Remember you just have 15 mins
*to save the world, before main starts up, so be quick.
**/
public static void save(List<EvilObject> evilObjects)
{
}
}
interface Destroy{
void destroy();
}
class EvilObject implements Destroy
{
public void destroy()
{
//This method has the power to destroy the world!
//To prevent any possible misuse, the code has been censored
//and is not published on twisters!
System.out.println("The world is destroyed!");
}
}
class GoodObject implements Destroy
{
public void destroy()
{
//This method does nothing. Its sole purpose is to replicate the EvilObject
//without doing any evil!!
System.out.println("The world is saved!");
}
}