Пример #1
0
    void SortMoleculesByBoilingPoint()
    {
        sortedMoleculesByBoilingPoint.Clear();

        foreach (KeyValuePair <string, int> firstMol in solutionMolecules)
        {
            float firstMolValue = moleculicon.GetMol(firstMol.Key).GetDensity();
            float secondMolValue;
            bool  foundSpot = false;

            foreach (string secondMol in sortedMoleculesByBoilingPoint.ToArray())
            {
                secondMolValue = moleculicon.GetMol(secondMol).GetDensity();

                if (firstMolValue < secondMolValue)
                {
                    sortedMoleculesByBoilingPoint.Insert(sortedMoleculesByBoilingPoint.IndexOf(secondMol), firstMol.Key);
                    foundSpot = true;
                    break;
                }
            }

            if (!foundSpot)
            {
                sortedMoleculesByBoilingPoint.Add(firstMol.Key);
            }
        }

        //debug
        foreach (string item in sortedMoleculesByBoilingPoint)
        {
            print("SOLUTION: sorted molecules item: " + item);
        }
    }
Пример #2
0
    public Solution React(Solution sol)
    {
        firstMol = FindFewestElectrons(sol);
        secondMol = FindLargestCompatable(sol);

        if (secondMol == "null")
        {
            sol.AddMolecule(moleculicon.GetMol(firstMol));
            sol.reacting = false;
            return sol;
        }

        //sol.RemoveMolecule(firstMol);
        //sol.RemoveMolecule(secondMol);

        Molecule newMolecule = Bond(firstMol, secondMol);
        sol.AddMolecule(newMolecule);

        firstMol = null;

        print("||RE|| combined " + firstMol + " and " + secondMol);

        return sol;
    }
Пример #3
0
    public void UpdateGUI()
    {
        textNotation.text  = "";
        textAmount.text    = "";
        textElectrons.text = "";
        textEL.text        = "";
        textBond.text      = "";
        textDensity.text   = "";
        textPolarity.text  = "";
        textState.text     = "";

        foreach (KeyValuePair <string, int> entry in sol.solutionMolecules)
        {
            Molecule mol = moleculicon.GetMol(entry.Key);
            textNotation.text  += mol.GetName() + "\n";
            textAmount.text    += entry.Value + "\n";
            textElectrons.text += mol.GetElectrons() + "\n";
            textEL.text        += mol.GetElectronegativity() + "\n";
            textBond.text      += mol.GetBondStrength() + "\n";
            textDensity.text   += mol.GetDensity() + "\n";
            textPolarity.text  += mol.GetPolarity() + "\n";
            textState.text     += mol.GetState() + "\n";
        }
    }