Package edu.illinois.cs.cs125.mp5.lib
Class ChemicalElement
- java.lang.Object
-
- edu.illinois.cs.cs125.mp5.lib.ChemicalElement
-
public final class ChemicalElement extends java.lang.Object
Represents an element, that is, a type of atom.You do not need to modify this class, but you will need to use its methods.
-
-
Field Summary
Fields Modifier and Type Field Description static ChemicalElement
BROMINE
Element 35, the third halogen, bromine.static ChemicalElement
CARBON
Element 6, carbon.static ChemicalElement
CHLORINE
Element 17, the second halogen, chlorine.static ChemicalElement
FLUORINE
Element 9, the first halogen, fluorine.static ChemicalElement
HYDROGEN
Element 1, hydrogen.static ChemicalElement
OXYGEN
Element 8, oxygen.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getSymbol()
Gets the element's symbol on the periodic table.int
getValence()
Gets the element's valence, that is, how many bonds an atom of this element should have.double
getWeight()
Gets the element's average atomic mass.java.lang.String
toString()
Gets a string representation of the element object.
-
-
-
Field Detail
-
CARBON
public static final ChemicalElement CARBON
Element 6, carbon.
-
HYDROGEN
public static final ChemicalElement HYDROGEN
Element 1, hydrogen.
-
OXYGEN
public static final ChemicalElement OXYGEN
Element 8, oxygen.
-
FLUORINE
public static final ChemicalElement FLUORINE
Element 9, the first halogen, fluorine.
-
CHLORINE
public static final ChemicalElement CHLORINE
Element 17, the second halogen, chlorine.
-
BROMINE
public static final ChemicalElement BROMINE
Element 35, the third halogen, bromine.
-
-
Method Detail
-
getSymbol
public java.lang.String getSymbol()
Gets the element's symbol on the periodic table.- Returns:
- The one- or two-letter element symbol.
-
getWeight
public double getWeight()
Gets the element's average atomic mass.- Returns:
- The atomic mass in grams per mole.
-
getValence
public int getValence()
Gets the element's valence, that is, how many bonds an atom of this element should have.- Returns:
- The valence.
-
toString
public java.lang.String toString()
Gets a string representation of the element object.- Overrides:
toString
in classjava.lang.Object
- Returns:
- The stringified element.
-
-