moved checksum function to its own interface

its not needed that all barcodes have an integer checksum
so it should not be needed in every implementation.
This commit is contained in:
Florian Sundermann committed 2017-01-26 08:20:38 +01:00
1 parent fe0f26ff6d
commit b066487b3e
11 files changed
+57 -34

No files matched your search

+14 -5
View File
@@ -10,8 +10,12 @@ import (
type base1DCode struct {
*BitList
kind string
content string
kind string
content string
}
type base1DCodeIntCS struct {
base1DCode
checksum int
}
@@ -38,11 +42,16 @@ func (c *base1DCode) At(x, y int) color.Color {
return color.White
}
func (c *base1DCode) CheckSum() int {
func (c *base1DCodeIntCS) CheckSum() int {
return c.checksum
}
// New1DCode creates a new 1D barcode where the bars are represented by the bits in the bars BitList
func New1DCode(codeKind, content string, bars *BitList, checksum int) barcode.Barcode {
return &base1DCode{bars, codeKind, content, checksum}
func New1DCodeIntCheckSum(codeKind, content string, bars *BitList, checksum int) barcode.BarcodeIntCS {
return &base1DCodeIntCS{base1DCode{bars, codeKind, content}, checksum}
}
// New1DCode creates a new 1D barcode where the bars are represented by the bits in the bars BitList
func New1DCode(codeKind, content string, bars *BitList) barcode.Barcode {
return &base1DCode{bars, codeKind, content}
}