| Developing with the SDK > Using and Writing Data Models > JavaBeans Example > The Atom, Bond, and Molecule Classes |
The Atom, Bond, and Molecule Classes |
INDEX
PREVIOUS
NEXT
|
The atoms and the bonds are represented in the application by the Java classes Atom and Bond. These classes obey the JavaBeans conventions, for example, the Atom class has a property called symbol which represents the abbreviated symbol of the element; this property can be accessed through the methods setSymbol and getSymbol.
Code Sample 2.1 shows part of the Atom class.
/** * A class that represents an atom. */ public class Atom { ... private String symbol; public String getSymbol() { return symbol; } public void setSymbol(String symbol) { this.symbol = symbol; } } |
The Atom class has also a name property (the name of the element) , and an id property, which identifies the atom in the molecule.
The Bond class has two properties firstAtom and secondAtom which contain the identifiers of the two atoms linked by the bond, and also a type property which can have the values single or double.
A molecule is represented by an instance of the class Molecule. A molecule contains a list of atoms and a list of bonds.
Code Sample 2.2 shows the Molecule class.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. Legal terms. | PREVIOUS NEXT |