2
1
Fork 0
pr3-ws202526/go/06-airport/airport/gate.go

64 lines
1.3 KiB
Go

package airport
import (
"math/rand"
"time"
)
var distantFuture = time.Unix(1<<63-1, 0) // Max value for Unix timestamp
type GateNumber int
type Gate struct {
id GateNumber
walkingTimeFromSecurity time.Duration
taxiTimeToRunway time.Duration
//TODO: extend
}
var _ BaggageProcessor = &Gate{}
func NewGate(id GateNumber, walkingTimeFromSecurity time.Duration, taxiTimeToRunway time.Duration) Gate {
return Gate{id,
walkingTimeFromSecurity,
taxiTimeToRunway,
}
}
func NewGates(count int) map[GateNumber]*Gate {
gates := make(map[GateNumber]*Gate)
for i := range count {
walkingTime := time.Duration(5+rand.Intn(6)) * time.Second
taxiTime := time.Duration(5+rand.Intn(6)) * time.Second
gate := NewGate(GateNumber(i+1), walkingTime, taxiTime)
gates[GateNumber(i+1)] = &gate
}
return gates
}
func (g *Gate) SetFlights(flights []Flight) {
//TODO: implement
}
// Blocks for the walking distance to the gate + the time until the passenger has boarded
func (g *Gate) Process(passenger Passenger) error {
//TODO: implement
return nil
}
// Blocks until departure (includes taxi time to runway)
func (g *Gate) ProcessAircraft(ac *Aircraft) {
//TODO: implement
}
func (g *Gate) ProcessBaggage(fn FlightNumber, b Baggage) error {
//TODO: implement
return nil
}
func (g Gate) Start() {
//TODO: implement
}