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

📄 rules.java

📁 采用Java3D,基于L-system
💻 JAVA
字号:
import java.util.Vector;/** * This class keeps an axiom (the initiating production) and a Vector of Rules. * Each Rule contains a variable, and a production which the variable stands * for. Rules are retrieved by the Interpreter--given a variable, getRule * passes back the corresponding production. * (called by: Lsystem.java, Interpreter.java); * * @author Scott Teresi, April 1999, www.teresi.us */public class Rules {  static Vector rules = new Vector();  static String axiom = new String();  public Rules () {  }  public void add (String str) {    if (str != null)      rules.addElement(new Rule(str));  }    public int size () {    return rules.size();  }  public void setAxiom (String str) {    axiom = str;  }  public String getAxiom () {    return axiom;  }  public static String getRule (char ruleChar) {    String production = new String();    for (int i = 0; i < rules.size(); i ++) {      Rule r = (Rule) rules.elementAt(i);      if (r.var == ruleChar)	production = r.production;    }    if (production == null)      System.out.println("No production for " + ruleChar);    return production;  }  public class Rule {    public char var;    public String production;    public Rule (String str) {      var = str.charAt(0);      production = str.substring(2, str.length());    }  }}

⌨️ 快捷键说明

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