Package edu.illinois.cs.cs125.mp5.lib
Class OrganicMoleculeBuilder
- java.lang.Object
-
- edu.illinois.cs.cs125.mp5.lib.OrganicMoleculeBuilder
-
- Direct Known Subclasses:
CyclicOrganicMoleculeBuilder
,LinearOrganicMoleculeBuilder
public abstract class OrganicMoleculeBuilder extends java.lang.Object
Provides a convenient way to construct OrganicMolecule objects. You do not need to use this class.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OrganicMoleculeBuilder.Substituent
Helps represent, build, and attach substituents to the backbone.static class
OrganicMoleculeBuilder.SubstituentType
Possible types of substituents.
-
Constructor Summary
Constructors Constructor Description OrganicMoleculeBuilder(int setCoreCarbons)
Creates an organic molecule builder.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
addSubstituent
public OrganicMoleculeBuilder addSubstituent(int position, OrganicMoleculeBuilder.Substituent substituent)
Adds a substituent to the backbone at the given position.- Parameters:
position
- The position.substituent
- The new substituent.- Returns:
- This builder.
-
getSubstituents
public OrganicMoleculeBuilder.Substituent[] getSubstituents(int position)
Gets all present substituents at the given position.- Parameters:
position
- The carbon in the base.- Returns:
- An array containing the carbon's substituents.
-
getCoreCarbons
public int getCoreCarbons()
Gets the number of carbons in the base chain/cycle of this molecule.- Returns:
- The number of core carbons.
-
finishBackbone
protected abstract void finishBackbone(BondedAtom first, BondedAtom[] firstBonds, BondedAtom last, BondedAtom[] lastBonds)
Completes the backbone as appropriate for the type of builder.- Parameters:
first
- The first backbone carbon.firstBonds
- The first carbon's connected atoms.last
- The last backbone carbon.lastBonds
- The last carbon's connected atoms.
-
build
public BondedAtom build()
Constructs a molecule.- Returns:
- An atom in the molecule.
-
freeValence
protected abstract int freeValence(int position)
Gets how many bonds of the given carbon are not satisfied in the backbone.- Parameters:
position
- The zero-based index of the carbon.- Returns:
- How many bonds the given carbon has yet to make.
-
-