> For the complete documentation index, see [llms.txt](https://scls-cs.gitbook.io/apcs-lab/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://scls-cs.gitbook.io/apcs-lab/apcsa-i-2023-fall/di-shi-si-zhou/bus-stop.md).

# Bus Stop

In this assignment, you will create a `Bus` class simulating the activity of a bus. A bus moves back and forth along a single route, making stops along the way. The stops on the route are numbered consecutively from 1 up to and including a number that is provided when the `Bus` object is created. You may assume that the number of stops will always be greater than 1.&#x20;

The bus starts at the first stop and is initially heading towards the last stop. At each step of the simulation, the bus is at a particular stop and is heading toward either the first or last stop. **When the bus reaches the first or last stop, it reverses direction.**&#x20;

The following table contains a sample code execution sequence and the corresponding results:

<table><thead><tr><th>Statement of Expression</th><th width="163">Value returned(blank if no value)</th><th>Comment</th></tr></thead><tbody><tr><td>Bus bus1 = new Bus(3);</td><td></td><td>The route for bus1 has three stops numbered 1~3</td></tr><tr><td>bus1.getCurrentStop();</td><td>1</td><td>bus1 is at stop 1 (first stop on the route).</td></tr><tr><td>bus1.move();</td><td></td><td>bus1 moves to the next stop (2)</td></tr><tr><td>bus1.getCurrentStop();</td><td>2</td><td>bus1 is at stop 2 .</td></tr><tr><td>bus1.move();</td><td></td><td>bus1 moves to the next stop (3)</td></tr><tr><td>bus1.getCurrentStop();</td><td>3</td><td>bus1 is at stop 3.</td></tr><tr><td>bus1.move();</td><td></td><td>bus1 moves to the next stop (2）</td></tr><tr><td>bus1.getCurrentStop();</td><td>2</td><td>bus1 is at stop 2.</td></tr><tr><td>bus1.move();</td><td></td><td>bus1 moves to the next stop (1）</td></tr><tr><td>bus1.move();</td><td></td><td>bus1 moves to the next stop (2）</td></tr><tr><td>bus1.getCurrentStop();</td><td>2</td><td>bus1 is at stop 2.</td></tr><tr><td>bus1.getCurrentStop();</td><td>2</td><td>bus1 is still at stop 2.</td></tr><tr><td>Bus bus2 = new Bus(5);</td><td></td><td>The route for bus2 has five stops numbered 1–5 .</td></tr><tr><td>bus1.getCurrentStop();</td><td>2</td><td>bus1 is still at stop.</td></tr><tr><td>bus2.getCurrentStop();</td><td>1</td><td>bus2 is at stop 1 (first stop on the route).</td></tr></tbody></table>

Write the complete Bus class, including the constructor and any required instance variables and methods. Your implementation must meet all specifications and conform to the example.

**Test your class in main() following the table above. If the expression has return value, PRINT IT.  That's how your pass the test.**


---

# 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:

```
GET https://scls-cs.gitbook.io/apcs-lab/apcsa-i-2023-fall/di-shi-si-zhou/bus-stop.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.
