Design Patterns Java™ Workbook

(Michael S) #1
Appendix B. Solutions

this.atomicWeight = atomicWeight;
}


public double getMoles(double grams)
{
return grams / atomicWeight;
}


public String getName()
{
return name;
}


public String getSymbol()
{
return symbol;
}


public double getAtomicWeight()
{
return atomicWeight;
}
}


public static Chemical getChemical(String name)
{
return (Chemical) chemicals.get(name.toLowerCase());
}
}

Free download pdf