Exemple #1
0
        public void AddBondElectron(Electron electron)
        {
            if (IsFull)
            {
                throw new ChemistryException("Adding a third electron to an orbital is forbidden");
            }
            if (IsEmpty)
            {
                throw new ChemistryException("Adding a bond electron to an empty orbital sounds like an error...");
            }
            var existingElectron = Electrons[0];

            if (existingElectron.Spin == electron.Spin)
            {
                electron.Spin = existingElectron.Spin.Invert();
            }
            Electrons.Add(electron);
        }
Exemple #2
0
 public void AddElectron(Electron electron)
 {
     if (IsFull)
     {
         throw new ChemistryException("Adding a third electron to an orbital is forbidden");
     }
     if (electron.AssociatedOrbital != null)
     {
         throw new ChemistryException("Cannot add electron to orbital which is already associated to another orbital");
     }
     if (!IsEmpty)
     {
         var existingElectron = Electrons[0];
         if (existingElectron.Spin == electron.Spin)
         {
             electron.Spin = existingElectron.Spin.Invert();
         }
     }
     Electrons.Add(electron);
     electron.AssociatedOrbital = this;
 }