push all exercices

This commit is contained in:
lbenedar
2026-02-21 14:09:13 +03:00
commit a94d994b8c
72 changed files with 787 additions and 0 deletions

BIN
ch8/2/ch8_2.exe Normal file

Binary file not shown.

38
ch8/2/ch8_2.go Normal file
View File

@@ -0,0 +1,38 @@
package main
import (
"fmt"
"strconv"
)
type Printable interface {
Number | NumberFloat
fmt.Stringer
}
type Number struct {
val int
}
func (num Number) String() string {
return string(strconv.Itoa(num.val))
}
type NumberFloat struct {
val float64
}
func (num NumberFloat) String() string {
return string(strconv.Itoa(int(num.val)))
}
func Print[T Printable](num T) {
fmt.Println(num)
}
func main() {
firstTest := Number{val: 5}
secondTest := NumberFloat{val: 7.2}
Print(firstTest)
Print(secondTest)
}

3
ch8/2/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module ch8_2
go 1.25.0