-
-
Notifications
You must be signed in to change notification settings - Fork 60
/
dimension.go
39 lines (30 loc) · 734 Bytes
/
dimension.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package gozxing
import (
"fmt"
errors "golang.org/x/xerrors"
)
type Dimension struct {
width int
height int
}
func NewDimension(width, height int) (*Dimension, error) {
if width < 0 || height < 0 {
return nil, errors.New("IllegalArgumentException")
}
return &Dimension{width, height}, nil
}
func (this *Dimension) GetWidth() int {
return this.width
}
func (this *Dimension) GetHeight() int {
return this.height
}
func (this *Dimension) Equals(other *Dimension) bool {
return this.width == other.width && this.height == other.height
}
func (this *Dimension) HashCode() int {
return this.width*32713 + this.height
}
func (this *Dimension) String() string {
return fmt.Sprintf("%dx%d", this.width, this.height)
}