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.ObjectRepresents 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 ChemicalElementBROMINEElement 35, the third halogen, bromine.static ChemicalElementCARBONElement 6, carbon.static ChemicalElementCHLORINEElement 17, the second halogen, chlorine.static ChemicalElementFLUORINEElement 9, the first halogen, fluorine.static ChemicalElementHYDROGENElement 1, hydrogen.static ChemicalElementOXYGENElement 8, oxygen.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetSymbol()Gets the element's symbol on the periodic table.intgetValence()Gets the element's valence, that is, how many bonds an atom of this element should have.doublegetWeight()Gets the element's average atomic mass.java.lang.StringtoString()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:
toStringin classjava.lang.Object- Returns:
- The stringified element.
-
-