> For the complete documentation index, see [llms.txt](https://ethan-lin.gitbook.io/refactoring/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ethan-lin.gitbook.io/refactoring/xiang-jin-mei-gui/12-task-9.md).

# 任务9：夺取最后的胜利

首先，要恭喜你成功地走到了这一步！我们已经剪除了一些较为简单的分支，剩下的那个分支也在不知不觉中褪去它可怖的面目。有了前面的经验，你甚至可能已经信心十足、跃跃欲试，准备夺取我们重构大业最后的全面胜利了。

相信到这里，我已经不需要告诉你应该干什么了。来吧，带着前面学到的全部知识，尽情地攻克阻挡在我们面前的最后一道障碍吧。

![](/files/-LrtW0kAn0rsyHcIRUTC)

## 你的任务

Java：

```
git checkout task-9-final-victory
./gradlew clean build
```

JavaScript：

```
git checkout task-9-final-victory
npm test
```

1. 消除剩余方法中的`if`条件，把商品相关的行为全部搬移到特定的子类中
2. 要求小步前进，每一步修改之后马上运行所有测试，确保软件行为不变


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://ethan-lin.gitbook.io/refactoring/xiang-jin-mei-gui/12-task-9.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
