Skip to content

Instantly share code, notes, and snippets.

@mkock
Created August 20, 2020 19:08
Show Gist options
  • Select an option

  • Save mkock/cc92cf66d7c2572d65e2685cb9a9231c to your computer and use it in GitHub Desktop.

Select an option

Save mkock/cc92cf66d7c2572d65e2685cb9a9231c to your computer and use it in GitHub Desktop.
Bus Ride, code snippet 12
// 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