PaulPaulAga

Untitled

Apr 1st, 2021
124
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "strings"
  6. )
  7.  
  8. type I interface {
  9.     Haha() string
  10.     Hoho() string
  11. }
  12.  
  13. type Nhehe struct {
  14.     N int
  15. }
  16.  
  17. func NewNhehe(n int) Nhehe {
  18.     return Nhehe{
  19.         N: n,
  20.     }
  21. }
  22.  
  23. func (n Nhehe) Haha() string {
  24.     return strings.Repeat("haha", n.N)
  25. }
  26.  
  27. func (n Nhehe) Hoho() string {
  28.     return strings.Repeat("hoho", n.N)
  29. }
  30.  
  31. type TwoHehe struct{}
  32.  
  33. func (n TwoHehe) Haha() string {
  34.     return "hahahaha"
  35. }
  36.  
  37. func (n TwoHehe) Hoho() string {
  38.     return "hohohoho"
  39. }
  40.  
  41. func  DoHahaHoho(haho I) {
  42.     fmt.Println(haho.Haha())
  43.     fmt.Println(haho.Hoho())
  44.     fmt.Println()
  45. }
  46.  
  47. func main() {
  48.     DoHahaHoho(NewNhehe(3))
  49.     DoHahaHoho(TwoHehe{})
  50. }
  51.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×