driver.java

来自「Java程序设计(美) David D. Riley著 机械工业出版社 书籍配套」· Java 代码 · 共 40 行

JAVA
40
字号
/**	Author: David D. Riley *		Date: Jan, 2005 *   Die Class Driver (Figure 7.33) */import java.awt.Color;public class Driver extends ThreeButtons {	private ThreeButtonFrame  window;	private Die die;	/**	post:	A window is displayed 	 *			and a shadowed die is centered in the window	 */	public Driver()   {        Rectangle theDieRect;		window = new ThreeButtonFrame("Die Driver");		window.setLayout(null);        window.setBackground(Color.darkGray);		die = new Die();        theDieRect = die.getDieRect();        theDieRect.setLocation(280, 230);        window.add(theDieRect, 0);		window.repaint();	}	    /**	post:	die.spotCount() == die.spotCount()@pre + 1 */	public void leftAction()   {		die.setSpotCount( die.spotCount()+1 );	}		/**	post:	the color of die is set to blue */	public void midAction()   {		die.setDieColor(Color.blue);	}		/**	post:	the color of die is set to white */	public void rightAction()   {		die.setDieColor(Color.white);	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?