经典java书籍《thinking in java(第三版)》的源码

源代码在线查看: controller.java

软件大小: 87 K
上传用户: wenyishizhu
关键词: java thinking in 书籍
下载地址: 免注册下载 普通下载 VIP

相关代码

				//: c08:controller:Controller.java
				// With Event, the generic framework for control systems.
				// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
				// www.BruceEckel.com. See copyright notice in CopyRight.txt.
				package c08.controller;
				import java.util.*;
				
				public class Controller {
				  // An object from java.util to hold Event objects:
				  private List eventList = new ArrayList();
				  public void addEvent(Event c) { eventList.add(c); }
				  public void run() {
				    while(eventList.size() > 0) {
				      for(int i = 0; i < eventList.size(); i++) {
				        Event e = (Event)eventList.get(i);
				        if(e.ready()) {
				          System.out.println(e);
				          e.action();
				          eventList.remove(i);
				        }
				      }
				    }
				  }
				} ///:~
							

相关资源