Created
August 20, 2020 19:08
-
-
Save mkock/cc92cf66d7c2572d65e2685cb9a9231c to your computer and use it in GitHub Desktop.
Bus Ride, code snippet 12
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
| // Prospect is a potential Passenger. Prospects wait at BusStops to board Buses. | |
| type Prospect struct { | |
| SSN string | |
| Destination *BusStop | |
| } | |
| // BusStop represents a place where a Bus can stop and signal to prospects (future passengers) | |
| // that they may board. | |
| type BusStop struct { | |
| Name string | |
| prospects []Prospect | |
| busses []Bus | |
| } | |
| // AddStop adds the given BusStop to the list of stops that the Bus will stop at. Each stop is visited in order. | |
| func (b *Bus) AddStop(busStop *BusStop) { | |
| b.stops = append(b.stops, busStop) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment