sdf
This commit is contained in:
@@ -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")
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
module main
|
||||
|
||||
go 1.24.6
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user