-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrary.go
More file actions
48 lines (41 loc) · 819 Bytes
/
Copy pathlibrary.go
File metadata and controls
48 lines (41 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
type Book struct {
ID string
Title string
Author string
Description string
}
type Member struct {
ID string
Name string
DOB string
}
type Library struct {
Books []Book
Members []Member
}
func (l *Library) AddBook(title, author, description string) {
id := generateBookID(GenerateTimestampBasedID())
book := Book{
ID: id,
Title: title,
Author: author,
Description: description,
}
l.Books = append(l.Books, book)
}
func (l *Library) AddMember(name, dob string) {
id := generateMemberID(GenerateTimestampBasedID())
member := Member{
ID: id,
Name: name,
DOB: dob,
}
l.Members = append(l.Members, member)
}
func (l *Library) GetBooks() []Book {
return l.Books
}
func (l *Library) GetMembers() []Member {
return l.Members
}