Java编程思想这本书很好

源代码在线查看: controller.java

软件大小: 376 K
上传用户: xushenghao001
关键词: Java 编程
下载地址: 免注册下载 普通下载 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);
				        }
				      }
				    }
				  }
				} ///:~
							

相关资源