01219343/unit/discount
ไปยังการนำทาง
ไปยังการค้นหา
- This exercise is part of 01219343-55.
The rules that a shop used to give discounts to customers are as follow.
- If the customer is a member:
- Always give at least 5% discount.
- If the price is at least 1,000.00 baht, give 10% discount.
- If the price is more than 500.00 baht, give 7% discount.
- For non-member customer:
- If the price is at least 1,000.00 baht, give 7% discount.
Develop a static method:
PriceCalculator.calculateDiscount(Customer customer, double price)
that returns the amount of discount a customer
should get when the price is price
You should stricly follow the TDD process (write test, watch the test fails, fixe the code, and repeat).
Use the following definition of Customer
:
public class Customer { private boolean isMember; Customer(boolean isMember) { this.isMember = isMember; } public void setMember(boolean isMember) { this.isMember = isMember; } public boolean isMember() { return isMember; } }