⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cardpile.java

📁 一些JAVA的小程序
💻 JAVA
字号:
////	Abstraction for piles of cards for Solitaire game//	written by Tim Budd, April 1997//import java.awt.*;import java.util.Stack;import java.util.EmptyStackException;public class CardPile {		// coordinates of the card pile	protected int x;	protected int y;	protected Stack thePile;		// constructor	CardPile (int xl, int yl) 		{ x = xl; y = yl; thePile = new Stack(); }		// access to cards are not overridden	public final Card top() { return (Card) thePile.peek(); }	public final boolean isEmpty() { return thePile.empty(); }	public final Card pop() {		try {			return (Card) thePile.pop();			} catch (EmptyStackException e) { return null; }		}		// the following are sometimes overridden	public boolean includes (int tx, int ty) {		return x <= tx && tx <= x + Card.width &&			y <= ty && ty <= y + Card.height;		}		public void select (int tx, int ty) {		// do nothing		}	public void addCard (Card aCard)  		{ thePile.push(aCard); }	public void display (Graphics g) {		g.setColor(Color.blue);		if (isEmpty())			g.drawRect(x, y, Card.width, Card.height);		else			top().draw(g, x, y);		}	public boolean canTake (Card aCard) {		return false; 		}}

⌨️ 快捷键说明

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