From d0f726621f0129a6016be80cba206caeda2c9280 Mon Sep 17 00:00:00 2001 From: Oliver Jakoubek Date: Sun, 28 Jun 2020 20:18:41 +0200 Subject: [PATCH] Add more than on product to a Route --- route.go | 6 +++++- route_info.go | 14 +++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/route.go b/route.go index 468c519..b564f9e 100644 --- a/route.go +++ b/route.go @@ -16,7 +16,7 @@ type Route struct { eaAddressDefinition int topsheetTemplateDirectory int editionName string - productReferenceNumber int + productReferenceNumbers []int ProductionDrops []*ProductionDrop } @@ -58,6 +58,10 @@ func (r *Route) GetRouteMessage() string { return info } +func (r *Route) AddProductReferenceNumber(prnr int) { + r.productReferenceNumbers = append(r.productReferenceNumbers, prnr) +} + func (r *Route) AddProductionDrop(pd *ProductionDrop) error { r.ProductionDrops = append(r.ProductionDrops, pd) return nil diff --git a/route_info.go b/route_info.go index 5b3380d..d0a7d15 100644 --- a/route_info.go +++ b/route_info.go @@ -16,7 +16,7 @@ type RouteInfo struct { eaAddressDefinition int topsheetTemplateDirectory int editionName string - productReferenceNumber int + productReferenceNumbers []int } func (ri *RouteInfo) ParameterSz() string { @@ -27,12 +27,16 @@ func (ri *RouteInfo) SetParameterSz(parameterSz int) { ri.parameterSz = parameterSz } -func (ri *RouteInfo) ProductReferenceNumber() string { - return fmt.Sprintf("+41%02d", ri.productReferenceNumber) +func (ri *RouteInfo) ProductReferenceNumbers() string { + var prreffmt string + for _, pr := range ri.productReferenceNumbers { + prreffmt += fmt.Sprintf("+41%02d", pr) + } + return prreffmt } -func (ri *RouteInfo) SetProductReferenceNumber(productReferenceNumber int) { - ri.productReferenceNumber = productReferenceNumber +func (ri *RouteInfo) AddProductReferenceNumber(productReferenceNumber int) { + ri.productReferenceNumbers = append(ri.productReferenceNumbers, productReferenceNumber) } func (ri *RouteInfo) TopsheetTemplateDirectory() string {