From 6dee39718ba0c541a4c15fae4f78cbe4ba14aa68 Mon Sep 17 00:00:00 2001 From: Oliver Stolle 3024383 <3024383@stud.hs-mannheim.de> Date: Tue, 21 Apr 2026 22:15:19 +0000 Subject: [PATCH] Implemented the security check --- go/06-airport/airport/securityCheck.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/go/06-airport/airport/securityCheck.go b/go/06-airport/airport/securityCheck.go index 85ff4ad..f3c822d 100644 --- a/go/06-airport/airport/securityCheck.go +++ b/go/06-airport/airport/securityCheck.go @@ -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 }