ผลต่างระหว่างรุ่นของ "01219343/unit/discount"
ไปยังการนำทาง
ไปยังการค้นหา
Jittat (คุย | มีส่วนร่วม) (หน้าที่ถูกสร้างด้วย '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% dis...') |
Jittat (คุย | มีส่วนร่วม) |
||
(ไม่แสดง 4 รุ่นระหว่างกลางโดยผู้ใช้คนเดียวกัน) | |||
แถว 1: | แถว 1: | ||
+ | : ''This exercise is part of [[01219343-55]].'' | ||
+ | |||
The rules that a shop used to give discounts to customers are as follow. | The rules that a shop used to give discounts to customers are as follow. | ||
* If the customer is a member: | * If the customer is a member: | ||
− | ** Always give at least 5% discount | + | ** Always give at least 5% discount. |
** If the price is at least 1,000.00 baht, give 10% 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 <code>customer</code> should get when the price is <code>price</code> | ||
+ | |||
+ | You should stricly follow the TDD process (write test, watch the test fails, fixe the code, and repeat). | ||
+ | |||
+ | Use the following definition of <code>Customer</code>: | ||
+ | |||
+ | <pre> | ||
+ | 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; | ||
+ | } | ||
+ | } | ||
+ | </pre> |
รุ่นแก้ไขปัจจุบันเมื่อ 16:34, 24 มกราคม 2556
- 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; } }