9. Message Filter
Message Filter
Assignment
Starting code
package main
type Message interface {
Type() string
}
type TextMessage struct {
Sender string
Content string
}
func (tm TextMessage) Type() string {
return "text"
}
type MediaMessage struct {
Sender string
MediaType string
Content string
}
func (mm MediaMessage) Type() string {
return "media"
}
type LinkMessage struct {
Sender string
URL string
Content string
}
func (lm LinkMessage) Type() string {
return "link"
}
// Don't touch above this line
func filterMessages(messages []Message, filterType string) []Message {
result:= []Message{}
for _, mesType:= range messages{
if mesType.Type() == filterType{
result = append(result, mesType)
}
}
return result
}