Class LinearOrganicMoleculeBuilder


  • public final class LinearOrganicMoleculeBuilder
    extends OrganicMoleculeBuilder
    Provides a convenient way to build and render linear/branched organic molecules. 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.
    • Constructor Detail

      • LinearOrganicMoleculeBuilder

        public LinearOrganicMoleculeBuilder​(int setCoreCarbons)
        Creates a builder for a linear/branched molecule.
        Parameters:
        setCoreCarbons - How many carbons there are in the starting chain.
    • Method Detail

      • finishBackbone

        protected void finishBackbone​(BondedAtom first,
                                      BondedAtom[] firstBonds,
                                      BondedAtom last,
                                      BondedAtom[] lastBonds)
        Does nothing - freeValence makes sure the right number of hydrogens is added.
        Specified by:
        finishBackbone in class OrganicMoleculeBuilder
        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.
      • freeValence

        protected int freeValence​(int position)
        Gets how many bonds a core carbon can make after inclusion in the backbone.
        Specified by:
        freeValence in class OrganicMoleculeBuilder
        Parameters:
        position - The zero-based carbon index.
        Returns:
        How many bonds of the given carbon are not satisfied in the backbone.