forked from steger/pr3-sose2026
Implemented the security check
parent
1b7756f3cd
commit
6dee39718b
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue