public abstract class OrganicMoleculeBuilder
extends java.lang.Object
SSSS TTTTT OOO PPPP ! S T O O P P ! SSS T O O PPPP ! S T O O P ! SSSS T OOO P !Do not modify this class! Changes will be overwritten during official grading.
Modifier and Type | Class and Description |
---|---|
static class |
OrganicMoleculeBuilder.Substituent
Helps represent, build, and attach substituents to the backbone.
|
static class |
OrganicMoleculeBuilder.SubstituentType
Possible types of substituents.
|
Constructor and Description |
---|
OrganicMoleculeBuilder(int setCoreCarbons)
Creates an organic molecule builder.
|
Modifier and Type | Method and Description |
---|---|
OrganicMoleculeBuilder |
addSubstituent(int position,
OrganicMoleculeBuilder.Substituent substituent)
Adds a substituent to the backbone at the given position.
|
BondedAtom |
build()
Constructs a molecule.
|
protected abstract void |
finishBackbone(BondedAtom first,
BondedAtom[] firstBonds,
BondedAtom last,
BondedAtom[] lastBonds)
Completes the backbone as appropriate for the type of builder.
|
protected abstract int |
freeValence(int position)
Gets how many bonds of the given carbon are not satisfied in the backbone.
|
int |
getCoreCarbons()
Gets the number of carbons in the base chain/cycle of this molecule.
|
OrganicMoleculeBuilder.Substituent[] |
getSubstituents(int position)
Gets all present substituents at the given position.
|
public OrganicMoleculeBuilder(int setCoreCarbons)
setCoreCarbons
- The number of core carbons.public OrganicMoleculeBuilder addSubstituent(int position, OrganicMoleculeBuilder.Substituent substituent)
position
- The position.substituent
- The new substituent.public OrganicMoleculeBuilder.Substituent[] getSubstituents(int position)
position
- The carbon in the base.public int getCoreCarbons()
protected abstract void finishBackbone(BondedAtom first, BondedAtom[] firstBonds, BondedAtom last, BondedAtom[] lastBonds)
first
- The first backbone carbon.firstBonds
- The first carbon's connected atoms.last
- The last backbone carbon.lastBonds
- The last carbon's connected atoms.public BondedAtom build()
protected abstract int freeValence(int position)
position
- The zero-based index of the carbon.