Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
69 lines
2.8 KiB
Markdown
69 lines
2.8 KiB
Markdown
# 1. Goal
|
|
A regional bus company collects the departure timetables of its depots. The
|
|
planning office needs one class that stores the departures of all depots and
|
|
answers two questions: which departure comes next at a stop, and which
|
|
departures a stop has.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- Package $TMP, client 001, SAP_BASIS 816.
|
|
- There are no seed objects. The class is new.
|
|
- A departure has a stop, a line, a departure time and the depot that reported
|
|
it.
|
|
|
|
# 4. Contract
|
|
Create the class {{P}}DEPARTURE_PLANNER in package $TMP.
|
|
The class is public and final. It has a public constructor without parameters.
|
|
|
|
The class declares these public types:
|
|
- TY_STOP: character, length 4.
|
|
- TY_LINE: character, length 6.
|
|
- TY_DEPOT: character, length 4.
|
|
- TY_TIME: a time of the system (type T, format HHMMSS).
|
|
- TY_DEPARTURE: a structure with the components STOP (TY_STOP), LINE (TY_LINE),
|
|
DEPART (TY_TIME) and DEPOT (TY_DEPOT), in this order.
|
|
- TT_DEPARTURES: a standard table of TY_DEPARTURE with an empty key.
|
|
|
|
The class has exactly these public methods:
|
|
- CONSTRUCTOR: no parameters.
|
|
- ADD_DEPOT: importing IV_DEPOT type TY_DEPOT and IT_DEPARTURES type
|
|
TT_DEPARTURES. No returning parameter.
|
|
- NEXT_DEPARTURE: importing IV_STOP type TY_STOP and IV_FROM type TY_TIME.
|
|
Returning RS_DEPARTURE type TY_DEPARTURE.
|
|
- DEPARTURES_AT_STOP: importing IV_STOP type TY_STOP. Returning RT_DEPARTURES
|
|
type TT_DEPARTURES.
|
|
- COUNT: no importing parameter. Returning RV_COUNT type I.
|
|
|
|
Do not add other public methods.
|
|
|
|
# 5. Business rules
|
|
1. ADD_DEPOT stores the departures of the given depot. The DEPOT component of
|
|
the input rows is not used. The class stores IV_DEPOT in the DEPOT component.
|
|
2. Two departures are equal if STOP, LINE and DEPART are equal. If an equal
|
|
departure is already stored, the new departure is ignored and the stored
|
|
departure does not change. This rule also applies to equal departures inside
|
|
one call of ADD_DEPOT.
|
|
3. COUNT returns the number of stored departures.
|
|
4. NEXT_DEPARTURE returns the stored departure of the given stop with the
|
|
smallest DEPART that is not before IV_FROM. "Not before" means
|
|
DEPART >= IV_FROM. If the stop has no such departure, the result is initial.
|
|
5. DEPARTURES_AT_STOP returns all stored departures of the given stop in
|
|
ascending order of DEPART. If two departures have the same DEPART, the
|
|
departure with the smaller LINE comes first. If the stop is not stored, the
|
|
result is empty.
|
|
6. An empty input table changes nothing.
|
|
|
|
# 6. Constraints
|
|
- Release target: 8.16.
|
|
- Coding standards: Clean ABAP. Method length below 40 statements. No global
|
|
variables. No comment that restates the code.
|
|
- Out of scope: no database access, no user interface, no change to other
|
|
objects.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|