package main

import (
	"fmt"
	"strings"
)

func main() {
	batTest()
	// ExampleStringer()
	// foo1()
	/*
		value1, value2, operation := readTask()

		switch v1 := value1.(type) {
		case float64:
			break
		default:
			fmt.Printf("value=%v: %T\n", v1, v1)
			return
		}

		switch v2 := value2.(type) {
		case float64:
			break
		default:
			fmt.Printf("value=%v: %T\n", v2, v2)
			return
		}

		switch op := operation.(type) {
		case string:
			if op == "+" {
				fmt.Printf("%.4f\n", value1.(float64)+value2.(float64))
			} else if op == "-" {
				fmt.Printf("%.4f\n", value1.(float64)-value2.(float64))
			} else if op == "*" {
				fmt.Printf("%.4f\n", value1.(float64)*value2.(float64))
			} else if op == "/" {
				fmt.Printf("%.4f\n", value1.(float64)/value2.(float64))
			}
		default:
			fmt.Printf("operation=%v: %T\n", op, op)
			return
		}

		// fmt.Println("value 1 - OK")
		// fmt.Println(value1, value2, operation)
	*/
}

func foo1() {
	// vi1, vi2, operation :=  readTask()
	// vi := [2]interface{}{vi1, vi2}
	var v1, v2 float64
	vf := [2]*float64{&v1, &v2}
	fmt.Println(vf)
	fmt.Printf("%v %T", vf, vf)
}

func readTask() (v1, v2, op interface{}) {
	v1 = 12.36
	v2 = 36.24
	op = "+"
	return
}

type Animal struct {
	Name string
	Age  uint
}

func (a Animal) String() string {
	return fmt.Sprintf("%v (%d)", a.Name, a.Age)
}

func ExampleStringer() {
	a := Animal{
		Name: "Gopher",
		Age:  2,
	}
	fmt.Println(a)
}

type Battery struct {
	capacity int
}

func (b Battery) String() string {
	var ret string = "["
	for i := 0; i < (10 - b.capacity); i++ {
		ret += " "
	}
	for i := 0; i < b.capacity; i++ {
		ret += "X"
	}
	ret += "]"

	return ret
}

func batTest() {
	// var batteryForTest Battery
	var charge string
	batteryForTest := Battery{}

	fmt.Scan(&charge)
	batteryForTest.capacity = strings.Count(charge, "1")
	fmt.Println(batteryForTest)
}
