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

📄 chemical.java

📁 java设计模式源码
💻 JAVA
字号:
package com.oozinoz.chemical;

/*
 * Copyright (c) 2001, 2005. Steven J. Metsker.
 * 
 * Steve Metsker makes no representations or warranties about
 * the fitness of this software for any particular purpose, 
 * including the implied warranty of merchantability.
 *
 * Please use this software as you wish with the sole
 * restriction that you may not claim that you wrote it.
 */

/**
 * This class represents a type of chemical.
 */
public class Chemical {
    private String name;

    private String symbol;

    private double atomicWeight;

    /**
     * Model a chemical such as saltpeter.
     * 
     * @param name
     *            The name of this chemical, such as "Saltpeter."
     * @param symbol
     *            The chemical symbol for this substance, such as "KNO3."
     * @param atomicWeight
     *            The atomic weight of this substance (101 for saltpeter).
     */
    Chemical(String name, String symbol, double atomicWeight) {
        this.name = name;
        this.symbol = symbol;
        this.atomicWeight = atomicWeight;
    }

    /**
     * @return The name of this chemical, such as "Saltpeter."
     */
    public String getName() {
        return name;
    }

    /**
     * @return The symbol for this chemical, such as "KNO3."
     */
    public String getSymbol() {
        return symbol;
    }

    /**
     * @return The atomic weight of this chemical (e.g. 101 for saltpeter).
     */
    public double getAtomicWeight() {
        return atomicWeight;
    }

    /**
     * @return Textual description of this chemical.
     */
    public String toString() {
        return name + "(" + symbol + ")[" + atomicWeight + "]";
    }
}

⌨️ 快捷键说明

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