# 새로운 할인 정책으로 변경, 개발

```java
package hello.core.discount;
  import hello.core.member.Grade;
  import hello.core.member.Member;
public class RateDiscountPolicy implements DiscountPolicy { private int discountPercent = 10; //10% 할인
      @Override
      public int discount(Member member, int price) {
 if (member.getGrade() == Grade.VIP) {
               return price * discountPercent /  100;
          } else {
return 0; }
} }
```

테스트 코드 작성

```java
package hello.core.discount;

import hello.core.member.Grade;
import hello.core.member.Member;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.*;

class RateDiscountPolicyTest {
    RateDiscountPolicy discountPolicy = new RateDiscountPolicy();

    @Test
    @DisplayName("VIP는 10% 할인이 적용되어야 한다")
    void vip_o(){
        //given
        Member member = new Member(1L,"memberVIP", Grade.VIP);
        //when
        int discount = discountPolicy.discount(member,10000);
        //then
        assertThat(discount).isEqualTo(1000);
    }
    @Test
    @DisplayName("VIP가 아니면 10% 할인이 적용되지 않아야 한다")
    void vip_x(){
        //given
        Member member = new Member(2L,"memberBASIC", Grade.BASIC);
        //when
        int discount = discountPolicy.discount(member,10000);
        //then
        //Assertions.assertThat(discount).isEqualTo(1000);//할인금액은 0이 되야함.
        assertThat(discount).isEqualTo(0);//할인금액은 0이 되야함.
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://heunnajo.gitbook.io/spring/2/undefined.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
