discountorder.java
来自「ssd3 java编程 EXAM1 原样上传即可」· Java 代码 · 共 79 行
JAVA
79 行
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 + =
减小字号Ctrl + -
显示快捷键?