Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.samkough.selfgeneration;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.Timer;
- import java.util.TimerTask;
- public class Main
- {
- // 1000 milliseconds == 1 second
- public long delay = 2000; // milliseconds
- public LoopTask task = new LoopTask();
- public Timer timer = new Timer("TaskName");
- public void start()
- {
- timer.cancel();
- timer = new Timer("TaskName");
- Date executionDate = new Date(); // no params = now
- timer.scheduleAtFixedRate(task, executionDate, delay);
- }
- public class LoopTask extends TimerTask
- {
- public ArrayList<Tiles> map = new ArrayList<Tiles>();
- public Tiles t1 = new Tiles();
- public StringBuilder builder = new StringBuilder();
- public String text = "";
- public void run()
- {
- // value instantiations
- map.add(t1);
- // gets rid of the commas and the brackets
- for (Tiles value : map)
- {
- builder.append(value);
- }
- text = builder.toString();
- System.out.println(text);
- }
- }
- public static void main(String[] args)
- {
- Main runner = new Main();
- runner.start();
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------
- package com.samkough.selfgeneration;
- import java.util.Random;
- public class Tiles
- {
- public static int counter;
- public int tileId;
- public String ground, hill;
- public Tiles()
- {
- tileId = counter;
- counter++;
- }
- // DIFFERENT TILES
- public String ground()
- {
- return "__________";
- }
- public String hill()
- {
- return " /\\ \n"
- + " / \\ \n"
- + " / \\ \n";
- }
- public void randomizer()
- {
- Random rand = new Random();
- // 50 is the maximum and the 1 is our minimum
- int n = rand.nextInt(50) + 1;
- }
- public String toString()
- {
- return ground() + "\n" + hill() + "";
- }
- }
- /*
- ground = "__________";
- hill = " /\\ \n"
- + " / \\ \n"
- + " / \\ \n";
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement