This commit is contained in:
Alexander Pivkin
2025-09-05 14:14:21 +03:00
parent d7dc52283a
commit fd57dc9b95
6 changed files with 109 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
package gadget
import "fmt"
type TapePlayer struct {
batteries string
}
func (t TapePlayer) Play(song string) {
fmt.Println("Playing", song)
}
func (t TapePlayer) Stop() {
fmt.Println("Stopped")
}
type TapeRecorder struct {
Microphones int
}
func (t TapeRecorder) Play(song string) {
fmt.Println("Playing", song)
}
func (t TapeRecorder) Stop() {
fmt.Println("Stopped")
}
+3
View File
@@ -0,0 +1,3 @@
module main
go 1.24.6
+26
View File
@@ -0,0 +1,26 @@
package main
import "main/gadget"
type Player interface {
Play(string)
Stop()
}
func playlist(device Player, songs []string) {
for _, song := range songs {
device.Play(song)
}
device.Stop()
}
func main() {
var player Player
player = gadget.TapePlayer{}
mixtape := []string{"Red Plesen'", "Coco Jambo","Barbied Girl"}
playlist(player,mixtape)
player = gadget.TapeRecorder{}
mixtape = []string{"Dectl'", "Carmen","Scatman"}
playlist(player,mixtape)
}