/** * Converts the molarity to the desired unit. * * @param before The molarity in mol/L * @return The molarity in the desired unit. */ public double getMolarity(double before) { double after = molarity.getBlankAmount(before); if (after != before) steps.add( Function.latex( before + " \\{mol}{L} = " + after + "\\frac{" + molarity.getUnitName() + "}{" + molarity.getUnit2Name() + "}")); return after; }
/** * Returns the value in the volume field, or Units.UNKNOWN_VALUE if blank. * * @return The entered volume. */ public double getVolume() { double amount = volume.getAmount(); if (amount == Units.UNKNOWN_VALUE) steps.add(Function.latex("\\text{" + name + " volume} = ?")); else steps.add(Function.latex("\\text{" + name + " volume} = " + amount + " L")); return amount; }
/** * Returns the value in the molarity field, or Units.UNKNOWN_VALUE if blank. * * @return The entered molarity. */ public double getMolarity() { double amount = molarity.getAmount(); if (amount == Units.UNKNOWN_VALUE) steps.add(Function.latex("\\text{" + name + " molarity} = ?")); else steps.add(Function.latex("\\text{" + name + " molarity} = " + amount + "\\frac{mol}{L}")); return amount; }
/** * Returns the smallest number of sig figs in these fields. * * @return The sig fig number to use. */ public int getSigFigs() { int sigFigs1 = volume.getSigFigs(), sigFigs2 = molarity.getSigFigs(); return sigFigs1 == -1 ? sigFigs2 : sigFigs2 == -1 ? sigFigs1 : Math.min(sigFigs2, sigFigs1); }
/** * Converts the volume to the desired unit. * * @param before The volume in L * @return The volume in the desired unit. */ public double getVolume(double before) { double after = volume.getBlankAmount(before); unit = volume.getUnitName(); if (after != before) steps.add(Function.latex(before + " L = " + after + " " + unit)); return after; }
/** * Sets the value of the volume enter field. * * @param amount The value to set. */ public void setVolume(double amount) { volume.setAmount(amount); }
/** * Sets the value of the molarity enter field. * * @param amount The value to set. */ public void setMolarity(double amount) { molarity.setAmount(amount); }