JMU
logoChemicalc.png
The Molecule Class


Introduction

Purpose: A Molecule is a composition of multiple Atom objects.

Molecule objects are mutable. To "build" a Molecule, one should first construct an "empty" Molecule and then add Atom objects (in, perhaps, differing weights) to it.

Details
Attributes:
This class must, at a minimum, contain the following private attributes:

    mass - An int containing the mass
    descriptor - A String containing the "chemical formula" (e.g., "H_2 O")

The Explicit Value Constructor:
This class must implement the following explicit value constructor:
    /**
     * Explicit Value Constructor
     *
     * Used to construct an "empty" molecule
     */
    public Molecule()
    {
    }
    
The add(Atom, int) Method:
This class must implement the following method:
    /**
     * Add an Atom to this Molecule
     *
     * This method modifies the mass attribute and the descriptor 
     * attribute.
     *
     * Note: By convention, one should add the more 
     * electropositive Atom objects before the more
     * electronegative Atom objects (e.g., for water, one should
     * add H,2 before O,1 resulting in H_2 O). 
     * This method does not enforce this convention (e.g.,
     * one could add O,1 before H,2 resulting in O H_2)
     *
     * @param  atom    The Atom to add
     * @param  amount  The amount of the Atom to add
     */
    public void add(Atom atom, int amount)
    {
    }
    
The getMolecularMass() Method:
This class must implement the following method:
    /**
     * Get the total molecular mass (i.e., the total mass number of
     * all of the Atom objects, weighted by their amount)
     *
     * @return  The molecular mass
     */
    public int getMolecularMass()
    {
    }
    
The toString() Method:
This class must implement the following method:
    /**
     * Get a String representation (sometimes called the descriptor)
     * of this Molecule (or the empty String "" if no Atom 
     * objects have been added to this Molecule).
     *
     * For example, the String representation of water is "H_2 O"
     * (i.e., 2 Hydrogen and 1 Oxygen) and the String representation
     * of sulfuric acid is "H_2 S O_4".
     *
     * @return  The String representation (or the empty String "")
     */
    public String toString()
    {
    }
    

Copyright 2013