What I am supposed to do:
Add some necessary statements to the
printOrderCost()
method in the main class so that this method computes and p
It is generally a bad idea to add strings up like you did, as Java will create a unique String for each addition, which causes some unnecessary overhead. You can either use a StringBuilder as a general-purpose tool, or, if you know the exact format of how the String should look like, you can use String.format(...).
Example:
public toString() {
return String.format("%-10s %2d %6.2f %6.2f", brand, quantity, itemCost, getCost());
}