- 浏览: 136446 次
- 性别:
- 来自: 福建省莆田市
-
文章分类
最新评论
-
houruiming:
tks for your info which helps m ...
setcontent和setcontentobject用的是同一片内存 -
turingfellow:
in.tftpd -l -s /home/tmp -u ro ...
commands -
turingfellow:
LINUX下的网络设置 ifconfig ,routeLINU ...
commands -
turingfellow:
安装 linux loopbackyum install um ...
commands
package jadex.examples.blocksworld;
import jadex.util.SimplePropertyChangeSupport;
import java.awt.*;
import java.beans.PropertyChangeListener;
/**
* A block in the blocks-world.
*/
public class Block
{
//-------- static part --------
/** The block counter. */
protected static int counter = 0;
//-------- attributes --------
/** The number of the block. */
protected int number;
/** The color of the block. */
protected Color color;
/** The block where this block is located on. */
protected Block lower;
/** The block located on upper of this block. */
protected Block upper;
/** The helper object for bean events. */
public SimplePropertyChangeSupport pcs;
/** The x translation for drawing (0-1). */
protected double dx;
/** The y translation for drawing (0-1). */
protected double dy;
//-------- constructors --------
/**
* Create a new block.
* @param color The color of the block.
* @param lower The block where this block is located on.
*/
public Block(Color color, Block lower)
{
this(++counter, color, lower);
}
/**
* Create a new block.
* @param number The number of the block.
* @param color The color of the block.
* @param lower The block where this block is located on.
*/
public Block(int number, Color color, Block lower)
{
this.number = number;
this.color = color;
this.pcs = new SimplePropertyChangeSupport(this);
stackOn(lower);
}
//-------- methods --------
/**
* Get the color of the block.
* @return The color of the block.
*/
public Color getColor()
{
return color;
}
/**
* Get the block where this block is located on.
* @return The block where this block is located on.
*/
public Block getLower()
{
return lower;
}
/**
* Check if this block is clear.
*/
public boolean isClear()
{
return upper==null;
}
/**
* Move this block on top of another block.
*/
public void stackOn(Block lower)
{
// Check if block can be moved.
if(!isClear())
{
throw new RuntimeException("Can only move clear blocks: "+this);
}
else if(lower==this)
{
throw new RuntimeException("Cannot move block on itself: "+this);
}
// Remove this block from old lower block.
if(this.lower!=null)
this.lower.removeBlock(this);
// Move to new block.
if(lower!=null)
{
// Check if there is space on block.
if(!lower.isClear())
{
throw new RuntimeException("Can only stack on clear blocks: "+lower);
}
lower.addBlock(this);
this.dx = Math.random();
this.dy = Math.random();
}
setLower(lower);
}
/**
* Set the lower block, where this block is located on.
* @param lower The lower block.
*/
protected void setLower(Block lower)
{
Block old = this.lower;
this.lower = lower;
this.pcs.firePropertyChange("lower", old, this.lower);
}
//-------- helper methods --------
/**
* Add a block to this block.
*/
protected void addBlock(Block block)
{
Block old = this.upper;
this.upper = block;
this.pcs.firePropertyChange("upper", old, this.upper);
}
/**
* Remove a block from this block.
*/
protected void removeBlock(Block block)
{
this.upper = null;
this.pcs.firePropertyChange("upper", block, null);
}
/**
* Create a string representation of this block.
*/
public String toString()
{
return "Block "+number;
}
/**
* Check for equality.
*/
public boolean equals(Object o)
{
return o instanceof Block
&& ((Block)o).number==number
&& ((Block)o).getColor().equals(getColor());
}
//-------- property methods --------
/**
* Add a PropertyChangeListener to the listener list.
* The listener is registered for all properties.
* @param listener The PropertyChangeListener to be added.
*/
public void addPropertyChangeListener(PropertyChangeListener listener)
{
pcs.addPropertyChangeListener(listener);
}
/**
* Remove a PropertyChangeListener from the listener list.
* This removes a PropertyChangeListener that was registered
* for all properties.
* @param listener The PropertyChangeListener to be removed.
*/
public void removePropertyChangeListener(PropertyChangeListener listener)
{
pcs.removePropertyChangeListener(listener);
}
}
import jadex.util.SimplePropertyChangeSupport;
import java.awt.*;
import java.beans.PropertyChangeListener;
/**
* A block in the blocks-world.
*/
public class Block
{
//-------- static part --------
/** The block counter. */
protected static int counter = 0;
//-------- attributes --------
/** The number of the block. */
protected int number;
/** The color of the block. */
protected Color color;
/** The block where this block is located on. */
protected Block lower;
/** The block located on upper of this block. */
protected Block upper;
/** The helper object for bean events. */
public SimplePropertyChangeSupport pcs;
/** The x translation for drawing (0-1). */
protected double dx;
/** The y translation for drawing (0-1). */
protected double dy;
//-------- constructors --------
/**
* Create a new block.
* @param color The color of the block.
* @param lower The block where this block is located on.
*/
public Block(Color color, Block lower)
{
this(++counter, color, lower);
}
/**
* Create a new block.
* @param number The number of the block.
* @param color The color of the block.
* @param lower The block where this block is located on.
*/
public Block(int number, Color color, Block lower)
{
this.number = number;
this.color = color;
this.pcs = new SimplePropertyChangeSupport(this);
stackOn(lower);
}
//-------- methods --------
/**
* Get the color of the block.
* @return The color of the block.
*/
public Color getColor()
{
return color;
}
/**
* Get the block where this block is located on.
* @return The block where this block is located on.
*/
public Block getLower()
{
return lower;
}
/**
* Check if this block is clear.
*/
public boolean isClear()
{
return upper==null;
}
/**
* Move this block on top of another block.
*/
public void stackOn(Block lower)
{
// Check if block can be moved.
if(!isClear())
{
throw new RuntimeException("Can only move clear blocks: "+this);
}
else if(lower==this)
{
throw new RuntimeException("Cannot move block on itself: "+this);
}
// Remove this block from old lower block.
if(this.lower!=null)
this.lower.removeBlock(this);
// Move to new block.
if(lower!=null)
{
// Check if there is space on block.
if(!lower.isClear())
{
throw new RuntimeException("Can only stack on clear blocks: "+lower);
}
lower.addBlock(this);
this.dx = Math.random();
this.dy = Math.random();
}
setLower(lower);
}
/**
* Set the lower block, where this block is located on.
* @param lower The lower block.
*/
protected void setLower(Block lower)
{
Block old = this.lower;
this.lower = lower;
this.pcs.firePropertyChange("lower", old, this.lower);
}
//-------- helper methods --------
/**
* Add a block to this block.
*/
protected void addBlock(Block block)
{
Block old = this.upper;
this.upper = block;
this.pcs.firePropertyChange("upper", old, this.upper);
}
/**
* Remove a block from this block.
*/
protected void removeBlock(Block block)
{
this.upper = null;
this.pcs.firePropertyChange("upper", block, null);
}
/**
* Create a string representation of this block.
*/
public String toString()
{
return "Block "+number;
}
/**
* Check for equality.
*/
public boolean equals(Object o)
{
return o instanceof Block
&& ((Block)o).number==number
&& ((Block)o).getColor().equals(getColor());
}
//-------- property methods --------
/**
* Add a PropertyChangeListener to the listener list.
* The listener is registered for all properties.
* @param listener The PropertyChangeListener to be added.
*/
public void addPropertyChangeListener(PropertyChangeListener listener)
{
pcs.addPropertyChangeListener(listener);
}
/**
* Remove a PropertyChangeListener from the listener list.
* This removes a PropertyChangeListener that was registered
* for all properties.
* @param listener The PropertyChangeListener to be removed.
*/
public void removePropertyChangeListener(PropertyChangeListener listener)
{
pcs.removePropertyChangeListener(listener);
}
}
发表评论
-
protocols
2011-04-03 19:22 929<!-- The protocols capabilit ... -
dfcap
2011-04-03 19:15 883<!-- The df capability has a ... -
booktrading /seller
2011-03-29 23:19 940<html><head><tit ... -
booktrading / manager
2011-03-29 23:18 1104<html><head><tit ... -
booktrading / common
2011-03-29 23:17 1001<html><head><tit ... -
booktrading / buyer
2011-03-29 23:13 859<!-- <H3>The buyer age ... -
tomcat的context说明书
2011-03-20 17:39 815http://tomcat.apache.org/tomcat ... -
msyql的select语法
2010-09-13 22:52 108513.2.7. SELECT语法 13.2.7.1. ... -
zotero与word集成
2010-09-11 08:50 1789Manually Installing the Zotero ... -
university 2/n
2010-08-24 07:54 904Chapter 1.Introduction of regis ... -
university 1/n
2010-08-24 07:53 954chapter? Introduction ?.?The st ... -
Sun Java Bugs that affect lucene
2010-08-23 08:59 741Sometimes Lucene runs amok of b ... -
Snowball分词
2010-08-22 13:07 1244using System; using Lucene.Net. ... -
penn tree bank 6/6
2010-08-20 07:09 92011 This use of 12 Contact the - ... -
penn tree bank 5/n
2010-08-19 07:40 932always errs on the side of caut ... -
penn tree bank 4/n
2010-08-19 07:39 8274. Bracketing 4.1 Basic Methodo ... -
penn tree bank 3/n
2010-08-15 23:31 8252.3.1 Automated Stage. During t ... -
penn tree bank 2/n
2010-08-15 23:30 1520Mitchell P Marcus et al. Buildi ... -
capabilities 3/3
2010-08-11 22:58 79201<capability xmlns="ht ... -
capabilities 2/3
2010-08-11 22:57 749Fig.3.Element creation cases:a) ...
相关推荐
staticBlock.java 演示静态块的使用 staticVar.java 定义静态变量 supplyTest.java 对象作为静态成员使用示例 trySwap.java 试图交换两个形参的值 useOnlyTest.java 创建多个对象,演示this的作用 ...
EarthForge 是一个用 Java 编写的基于块的 2D 生存游戏。它建立在 UtiliGame 引擎之上。 文件 EarthForge-master.zip 具有以下条目。 EarthForge Readme.txt/* w ww ....src/com/earthforge/obj/Block.java
- `Block.java`: - 包含一个ImageIcon对象表示方块上的图标。 - 提供了设置和获取图标的接口`setOpenStateIcon`和`getOpenStateIcon`。 - `ShowRecordDialog.java`: - 保存了成绩文件和清除按钮等成员变量。 ...
- “Block.java” 可能被误识别为“BlockJbubtton” - “Record.java” 被误识别为“Record4.Record” 在实际的编程实践中,需要仔细检查代码和文档,并对上述的错误进行校正。 ### 总结 这份报告所描述的记忆...
设计内容主要包括多个Java源文件,如MineGame.java、MineArea.java、Block.java、BlockView.java、LayMines.java、Record.java、ShowRecord.java、voiceShow.java、userDefine.java、autherShow.java和ruleShow.java...
这里我们分析给定的四个关键文件:Block.java、LayMines.java、BlockView.java 和 MineFrame.java。 1. **Block.java**: 这个文件定义了扫雷游戏中最基本的单元——`Block`类。`Block`类代表游戏中的一个格子,它...
- 游戏的实现涉及7个Java源文件,包括PuzzleGame.java、PuzzlePad.java、Point.java、Block.java、HandleImage.java、VerifySuccess.java和HandleMove.java。 - 需要利用Java提供的关键类,如JMenuItem、JButton和...
总的来说,`MemoryBlock`的设计和实现涉及了Java内存管理的高级话题,对于理解和优化Java程序的内存性能具有重要意义。通过深入研究这个代码示例,开发者可以提升对Java内存机制的理解,进而编写出更高效、更稳定的...
#### 2.3 `Block.java` - **成员变量**:`ImageIcon openStateIcon`存储方块当前显示的图标。 - **方法**:`setOpenStateIcon(ImageIcon)`设置图标,`getOpenStateIcon()`获取图标。 #### 2.4 `ShowRecordDialog....
在Java中,`java.security.Key`接口和`javax.crypto.KeyGenerator`类可用于生成和管理密钥。 2. 模式选择:AES支持多种工作模式,如ECB(Electronic Codebook)、CBC(Cipher Block Chaining)、CFB(Cipher ...
本篇文章将围绕“Java_game_russia-Block.zip”这一项目,详细介绍一个基于Java实现的网络版俄罗斯方块游戏的课程设计,以及其背后涉及的重要知识点。 首先,让我们理解项目的背景。这个课程设计旨在构建一个网络...
在Java编程领域,"ReadBlock.zip" 文件似乎与Oracle数据库中的数据块读取操作有关。Oracle数据库是一个广泛使用的关系型数据库管理系统,它以数据块为基本的存储单元。在这个项目中,我们有一个名为 "ReadBlock.java...
系统主要由7个Java源程序构成:Memory.java、MemoryTestPane.java、Block.java、ShowRecord.java、Record.java、People.java、RandomSetIcon.java。此外,还使用了Java系统提供的关键类。系统流程图展示了这些类及...
3. `Block.java` - 表示游戏中的一个方块,包含雷的状态和位置信息。 4. `BlockView.java` - 方块的视图,负责显示方块的外观。 5. `LayMines.java` - 雷的布局,用于随机生成雷的位置。 6. `ShowRecord.java` - ...
首先,我们来看关键的三个类:Operation.java、Block.java和My2048.java。这三个文件构成了游戏的核心逻辑和界面展示。 1. Operation.java:这个类很可能负责处理用户的所有操作,如滑动事件。在2048游戏中,滑动是...
而`Block.java`可能是表示游戏中的每个图片块的类,包含了图片信息和状态(翻开或未翻开)。 至于图片文件,如`ani5.jpg`、`car3.jpg`、`car5.jpg`等,它们是游戏中的实际图片资源,可能被用作游戏中的卡片图案,...
4. Block.java - 表示方块,存储数值或图像信息。 5. HandleImage.java - 处理图像操作,如分割和重组。 6. VerifySuccess.java - 检查游戏是否成功,即方块或图像是否已正确排序。 7. HandleMove.java - 管理方块的...
3. **Block.java**:`Block`类扩展自`JButton`,为`MemoryTestArea`的`ArrayList<Block>`提供实例。每个`Block`对象代表游戏中的一个可点击方块,可以设置和获取其状态图标,允许游戏逻辑检查和更新方块的状态。 4....
文件名可能会进一步细分为如GameBoard.java(游戏板)、Block.java(方块类)、Player.java(玩家控制)和Controller.java(事件处理器)等,每个类负责不同的功能。 详细知识点: 1. 面向对象编程:Java是一种面向...