argumentset.java
来自「Calculator:可以计算各种基础表达式的计算器,比如3x+5x^2(x=3」· Java 代码 · 共 42 行
JAVA
42 行
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Calculator;
/**
*
* @author asus
*/
import java.util.HashMap;
/*I use hash map to store the arg,
* put(K key, V value) to store
* get(Object key) to get the value*/
public class ArgumentSet {
private HashMap<String, Double> args;
public ArgumentSet() {
args = new HashMap<String, Double>();
}
public void setArg(String name, double value) {
args.put(name, value);
//value is automatically cast to Double Class
}
public int sizeOfArgs(){
return args.size();
}
public double getArg(String name) {
Double result = args.get(name);
if (result == null) {
return 0.0;
} else {
return result;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?