Calculate
Total Price Exercise
Accept 3 inputs from the user:
● How many items
● Price per item
● 2-letter state code
Output the total price. Give a discount based on the
total price, add state tax based on the state and the discounted price.
Order Value
|
Discount Rate
|
$1000
|
3%
|
$5000
|
5%
|
$7000
|
7%
|
$10000
|
10%
|
$50000
|
15%
|
State
|
Tax Rate
|
UT
|
6.85%
|
NV
|
8.00%
|
TX
|
6.25%
|
AL
|
4.00%
|
CA
|
8.25%
|
Acceptance
Tests:
First Test
When an item price is 493.87
And an item quantity is 15
And a state is CA
Then the total price is 7,457.87
Second Test
When an item price is 1,493.87
And an item quantity is 825
And a state is UT
Then the total price is 1,119,335.32
Implement Test Driven Development Methodology
Implement Test Driven Development Methodology
- 必须知道什么是TDD以及TDD的Best Practice
- 得分点: 分成两个文件夹Test 和 Java
- 得分点: 先写测试
- 得分点:测试类名必须是XXXTest.java
- 得分点:测试类和被测试类必须在同一个package里面,例如model
- 熟悉JUnit API了解 assertEquals方法如何测试double类型
- 计算折扣的业务逻辑非常容易搞错
- floating point numbers are not perfectly precise
- price 设计成 int 表示美分也是也是一个重要的点
No comments:
Post a Comment