Java类Product里面的变量名称
java类 Basket里面的Basket constructor和getTotalCost()的代码
要求Basket后面那个函数能计算所有物品的总价。
我记得以前作业的代码用的是collection做的。
这个考试可能会考, 作业的代码被我弄丢了。。
------解决方案--------------------------------------------------------
- Java code
public class ShoppingBasket{ Map<Product, Integer> items;}public class Product implements Comparable<Product>{ double price; String name;String id;}