Commit 172f1b99 authored by Caelan Reese Wong's avatar Caelan Reese Wong
Browse files

Merge branch 'deleteMolecule' into 'master'

updated the delete function to fix array index issue

See merge request ec504/ec504_projects/group4!15
parents 0d829fb8 b448a7ff
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -162,6 +162,10 @@ public class MDB {
            Molecule result = dbMolecule.areMoleculesEqual(molecule);
            if (result != null) {
                this.db.get(numAtoms).remove(dbMolecule);
                if( this.db.get(numAtoms).size()==0 )
                {
                    this.db.remove(numAtoms); //prevents array index error when key becomes empty
                }
                return true; // successfully delete the molecule
            }
        }
+4 −0
Original line number Diff line number Diff line
@@ -193,6 +193,10 @@ public class MoleculeDatabase {
            Molecule result = dbMolecule.areMoleculesEqual(molecule);
            if (result != null) {
                this.db.get(numAtoms).remove(dbMolecule);
                if( this.db.get(numAtoms).size()==0 )
                {
                    this.db.remove(numAtoms); //prevents array index error when key becomes empty
                }
                return true; // successfully delete the molecule
            }
        }