OOP designs

Design A Book App

~2 mins read

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
class Author:
    name: str 

class Genre:
    name: str

class File: 
    name: str
    size: int 

class TextFile(File):
    ...

class AudioFile(File):
    ...

class Book: 
    name: str 
    authors: List[Author]
    genres: List[Genre] 
    text: TextFile
    audio: AudioFile

    class get_text():
        ...

    class get_audio():
        ...

class Reader:
    def read_text(book:Book):
        ...

class Player:
    def play_audio(book:Book):
        ...

class Library:
    books: List[Book]

    def search():
        ... 

    def add_book(book:Book):
        ...

class Shelf:
    books: List[Book]

    def add_book():
        ...

    def remove_book():
        ...

class User: 
    username: str 
    password_hash: str 
    shelves: List[Shelf]

    def auth():
        ... 

🎰