Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package myStuff;
- import java.util.ArrayList;
- import java.util.List;
- import guiTeacher.components.Action;
- import guiTeacher.components.Button;
- import guiTeacher.components.TextArea;
- import guiTeacher.interfaces.Visible;
- import guiTeacher.userInterfaces.ClickableScreen;
- public class Game extends ClickableScreen implements Runnable {
- private static final long serialVersionUID = -8829654677685378367L;
- private TextArea txt;
- private Button button1;
- private int count;
- private int time;
- private TextArea finalTxt;
- public Game(int width, int height) {
- super(width, height);
- count = 0;
- time = 10;
- Thread app = new Thread(this);
- app.start();
- }
- public Game(int width, int height, ArrayList<Visible> initWithObjects) {
- super(width, height);
- }
- @Override
- public void run() {
- for(int i = time; i > 0; i--) {
- time--;
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- txt.setText("Times Clicked: " + count + " Time Left: " + time);
- }
- button1.setEnabled(false);
- finalTxt.setText("Final Score: " + count );
- }
- @Override
- public void initAllObjects(List<Visible> viewObjects) {
- txt = new TextArea(250,100,250,200, "Times Clicked: " + count + " Time Left: " + time);
- button1 = new Button(100,100,100,100, "Click", new Action() {
- @Override
- public void act() {
- count++;
- txt.setText("Times Clicked: " + count + " Time Left: " + time);
- }
- });
- finalTxt = new TextArea(250,400,100,100, "");
- viewObjects.add(button1);
- viewObjects.add(txt);
- viewObjects.add(finalTxt);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement