1
0
Fork 0

Implemented the security check

main
Oliver Stolle 2026-04-21 22:15:19 +00:00
parent 1b7756f3cd
commit 6dee39718b
1 changed files with 24 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package airport
import (
"fmt"
"time"
)
@ -19,7 +20,6 @@ func NewSecurityCheck(processingTime time.Duration) SecurityCheck {
// processes one passenger at a time. Each passenger must at least spend the processingTime at the security check
func (sc *SecurityCheck) Start() {
//TODO: implement
}
// returns an error if
@ -27,6 +27,28 @@ func (sc *SecurityCheck) Start() {
// - the passenger's boardings pass does not match the name
// - the passenger carries a prohibited item
func (sc SecurityCheck) Process(p Passenger) error {
//TODO: implement
time.Sleep(sc.processingTime)
if p.BoardingPass == nil {
return fmt.Errorf("%v has no boarding pass!", p.Name)
}
if p.BoardingPass.Name != p.Name {
return fmt.Errorf("Name on boaring pass (%v) doesn't match with passengers name (%v)!", p.BoardingPass.Name, p.Name)
}
for bagNr, bag := range p.Bags {
for _, item := range bag.Items {
if prohibitedItems[item] {
return fmt.Errorf("Found %v in bag %v which is a prohibited item!", item, bagNr)
}
}
}
for _, item := range p.CarryOnItems {
if prohibitedItems[item] {
return fmt.Errorf("Found %v on %v which is a prohibited item!", item, p.Name)
}
}
return nil
}