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

📄 argumentset.java

📁 Calculator:可以计算各种基础表达式的计算器,比如3x+5x^2(x=3)
💻 JAVA
字号:
/*
 * 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -