/*
* We are going to calculate the amount which is needed to cover one surface.
* The flooring is always placed crosswise relative to the length of the surface.
* If you want to find the amount the other way, you have to change
* width and length in the surface argument.
*/
public double getNoOfMeters(Surface aSurface) {
double lengthSurface = aSurface.getLength();
double widthSurface = aSurface.getWidth();
int noOfWidths = (int)(lengthSurface / widthOfFlooring);
double rest = lengthSurface % widthOfFlooring;
if (rest >= limit) noOfWidths++;
return noOfWidths * widthSurface;
}
public double getTotalPrice(Surface aSurface) {
return getNoOfMeters(aSurface) * price;
}
}
以上三個類之間的類圖關系可以表示為如下圖:
延伸閱讀
文章來源于領測軟件測試網 http://www.kjueaiud.com/