CreateBoss [source code]

public class CreateBoss {
    private long startTime = System.currentTimeMillis();
    public int bossCount = 0;

    public int getCurTime() {return (int)(System.currentTimeMillis() - startTime)/1000;}
    public void newBoss() {System.out.println("New Boss!");}
    public int random() { return (int)(Math.random() * 10000);}

    public static void main(String[] arg) {
        CreateBoss bossFactory = new CreateBoss();
        while (true) {
            if (bossFactory.getCurTime()/7200 + 1 > bossFactory.bossCount) {
                System.out.printf("Current count is %d and current run time is %d%n", 
                    bossFactory.bossCount, bossFactory.getCurTime());
                int createTime = bossFactory.random()%7200;
                System.out.printf("Creating boss at in %d seconds %n", createTime);
                while(true) {
                    if (bossFactory.getCurTime()%7200 == createTime) {
                        bossFactory.newBoss();
                        bossFactory.bossCount++;
                        break;
                    }
                }
            }
        }
    }
}

results matching ""

    No results matching ""