phone_number.go 417 B

1234567891011121314151617181920212223
  1. package biz
  2. import "fmt"
  3. type PhoneNumber struct {
  4. Phone string
  5. AreaCode string
  6. }
  7. func NewPhoneNumber(phone, areaCode string) *PhoneNumber {
  8. return &PhoneNumber{
  9. Phone: phone,
  10. AreaCode: areaCode,
  11. }
  12. }
  13. func (p PhoneNumber) String() string {
  14. return fmt.Sprintf("%s %s", p.AreaCode, p.Phone)
  15. }
  16. func (p PhoneNumber) Eq(p2 *PhoneNumber) bool {
  17. return p.Phone == p2.Phone && p.AreaCode == p2.AreaCode
  18. }