📄 basket.java
字号:
/**
* Each dustomer has a basket.
* The basket class is used by BasketController.
* A basket object contains a collection class (products vector)
* which contains the product the dustomer would like to buy.
*/
import java.util.*;
public class Basket {
private Vector products;
/**
* Class constructor.
*/
public Basket(){
products=new Vector();
}
/**
* Add a product to a customer's basket.
* In this method, we just need add it to the collection class of the basket.
*
* @param p the product's object to added.
*/
public void add(Product p){
//body
}
/**
* Delete a product from a customer's basket.
* In this method, we just need to remove it from the basket's collection class.
*
* @param p the product's object to be deleted.
*/
public void delete(Product p){
//body
}
/**
* Clear all the products in the basket if the customer would like.
* the method invoke the vector's clear method to clear the collection class.
*
*/
public void clear(){
//body
}
/**
* Gets products of the basket.
*
* @return the collection class(vector) of this class
*/
public Vector getProducts(){
return products;
}
/**
* Set products of the basket.
*
* @param products a vector
*/
public void setProducts(Vector products){
this.products=products;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -