Add string methods

master
Buddy Sandidge 5 years ago
parent 0943ed42dd
commit 1c7732cf32

@ -45,7 +45,7 @@ func New(args ...string) (*App, error) {
func (a *App) Run() error { func (a *App) Run() error {
fmt.Printf("target: %d\n", a.Target) fmt.Printf("target: %d\n", a.Target)
for i, bucket := range a.Buckets { for i, bucket := range a.Buckets {
fmt.Printf("bucket %d: %d\n", i+1, bucket.Capacity) fmt.Printf("bucket %d: %s\n", i+1, bucket.String())
} }
return nil return nil
} }

@ -1,5 +1,7 @@
package bucket package bucket
import "fmt"
// Bucket to store volume // Bucket to store volume
type Bucket struct { type Bucket struct {
// Capacity amount the bucket can store // Capacity amount the bucket can store
@ -29,3 +31,8 @@ func (b *Bucket) Pour(target *Bucket) {
target.Volume += availableVolume target.Volume += availableVolume
} }
} }
// String gets string representation
func (b *Bucket) String() string {
return fmt.Sprintf("%dvol/%dcap", b.Volume, b.Capacity)
}

Loading…
Cancel
Save