Created
August 20, 2020 19:17
-
-
Save mkock/daa21af2d20f4bb80245568fc9a5ebd5 to your computer and use it in GitHub Desktop.
Bus Ride, code snippet 19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // NotifyBusArrival is called by Bus upon arrival. | |
| func (b *BusStop) NotifyBusArrival(bus *Bus) { | |
| for _, p := range b.prospects { | |
| if bus.StopsAt(p.Destination) { | |
| bus.Add(p.ToPassenger()) | |
| } | |
| } | |
| } | |
| // Equals returns true if the given BusStop is the same as the receiver. | |
| func (b *BusStop) Equals(busStop *BusStop) bool { | |
| return b.Name == busStop.Name | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment