📄 discountorder.java
字号:
import java.util.*;
/**
* This class models extend class {@link Order} adding the
* following information:
* <ol>
* <li> The strategy of discount applied to this order </li>
* </ol>
*
* @author iCarnegie
* @version 1.0.0
* @see DiscountStrategy
*/
public class DiscountOrder extends Order {
/* The discount strategy applied to this order */
private DiscountStrategy discountStrategy;
/**
* Creates a <code>DiscountOrder</code> object with a cash discount
*
* @param initCustomer the customer that place the order
* @param initDate the date of the order
* @param initDiscountStrategy the discount strategy applied to this order
*/
public DiscountOrder(
Customer initCustomer,
Date initDate,
DiscountStrategy initDiscountStrategy) {
super(initCustomer, initDate);
discountStrategy = initDiscountStrategy;
}
/**
* Returns the {@link DiscountStrategy} object of this order.
*
* @return the {@link DiscountStrategy} object of this order.
*/
public DiscountStrategy getDiscountStrategy() {
return discountStrategy;
}
/**
* Modifies the {@link DiscountStrategy} object of this order.
*
* @param newDiscountStrategy the new {@link DiscountStrategy} object of
* this order.
*/
public void setDiscountStrategy(DiscountStrategy newDiscountStrategy) {
discountStrategy = newDiscountStrategy;
}
/**
* Returns the discounted cost of the order.
*
* @return the discounted cost of the order.
*/
public double getTotalCostAfterDiscount() {
/* PLACE YOUR CODE HERE */
return 0.0; // REMOVE; USED SO THIS FILE COMPILES
}
/**
* Returns the string representation of this order.
*
* @return the string representation of this order.
*/
public String toString() {
/* PLACE YOUR CODE HERE */
return ""; // REMOVE; USED SO THIS FILE COMPILES
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -