/*
* 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;
}
}
以上三个类之间的类图关系可以表示为如下图:
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/