├── README.md ├── main.py └── pictures ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png └── 7.png /README.md: -------------------------------------------------------------------------------- 1 | # Data-Base-Assignment-3 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | class SocialMedia: 2 | def __init__(self): 3 | self.name = None 4 | 5 | def give_name(self, name): 6 | self.name = name 7 | 8 | def get_name(self): 9 | return self.name 10 | 11 | 12 | class Instagram(SocialMedia): 13 | def __init__(self): 14 | self.give_name("Instagram") 15 | self.user = [] 16 | self.password = [] 17 | self.post = [[None for _ in range(150)] for _ in range(50)] 18 | 19 | def sign_up(self): 20 | username = input("Please enter your username : ") 21 | password = input("Please enter your password : ") 22 | self.user.append(username) 23 | self.password.append(password) 24 | 25 | def check(self, username_, password_): 26 | for counter in range(len(self.user)): 27 | if username_ == self.user[counter] and password_ == self.password[counter]: 28 | return True 29 | 30 | def give_user_num(self, username_): 31 | for counter in range(len(self.user)): 32 | if username_ == self.user[counter]: 33 | return counter 34 | return -1 35 | 36 | def give_post_num(self, username_): 37 | num = self.give_user_num(username_) 38 | for counter2 in range(50): 39 | if self.post[num][counter2] is None: 40 | return counter2 41 | return -1 42 | 43 | def publish_new_post(self): 44 | username = input("Please enter your username : ") 45 | password = input("Please enter your password : ") 46 | if self.check(username, password): 47 | post = input("You can write down your post : ") 48 | if len(post) < 2200: 49 | row = self.give_user_num(username) 50 | column = self.give_post_num(username) 51 | self.post[row][column] = post 52 | else: 53 | print("your post is too long!") 54 | else: 55 | print("your username or password is wrong!") 56 | 57 | def get_posts(self): 58 | username = input("Please enter your username : ") 59 | password = input("Please enter your password : ") 60 | if self.check(username, password): 61 | for counter in range(self.give_post_num(username)): 62 | print(self.post[self.give_user_num(username)][counter]) 63 | else: 64 | print("your username or password is wrong!") 65 | 66 | 67 | class Twitter(SocialMedia): 68 | def __init__(self): 69 | self.give_name("Twitter") 70 | self.user = [] 71 | self.password = [] 72 | self.post = [[None for _ in range(150)] for _ in range(50)] 73 | 74 | def sign_up(self): 75 | username = input("Please enter your username : ") 76 | password = input("Please enter your password : ") 77 | self.user.append(username) 78 | self.password.append(password) 79 | 80 | def check(self, username_, password_): 81 | for counter in range(len(self.user)): 82 | if username_ == self.user[counter] and password_ == self.password[counter]: 83 | return True 84 | 85 | def give_user_num(self, username_): 86 | for counter in range(len(self.user)): 87 | if username_ == self.user[counter]: 88 | return counter 89 | return -1 90 | 91 | def give_post_num(self, username_): 92 | num = self.give_user_num(username_) 93 | for counter2 in range(50): 94 | if self.post[num][counter2] is None: 95 | return counter2 96 | return -1 97 | 98 | def create_new_tweet(self): 99 | username = input("Please enter your username : ") 100 | password = input("Please enter your password : ") 101 | if self.check(username, password): 102 | post = input("You can write down your post : ") 103 | if len(post) < 280: 104 | row = self.give_user_num(username) 105 | column = self.give_post_num(username) 106 | self.post[row][column] = post 107 | else: 108 | print("your post is too long!") 109 | else: 110 | print("your username or password is wrong!") 111 | 112 | def get_tweets(self): 113 | username = input("Please enter your username : ") 114 | password = input("Please enter your password : ") 115 | if self.check(username, password): 116 | for counter in range(self.give_post_num(username)): 117 | print(self.post[self.give_user_num(username)][counter]) 118 | else: 119 | print("your username or password is wrong!") 120 | 121 | 122 | if __name__ == '__main__': 123 | Insta = Instagram() 124 | Twit = Twitter() 125 | command = "" 126 | command2 = "" 127 | command3 = "" 128 | while command != "3": 129 | print("Please write command!") 130 | print("1 to Open Instagram") 131 | print("2 to Open Twitter") 132 | print("3 to Exit") 133 | print() 134 | print() 135 | print() 136 | command = input() 137 | if command == "1": 138 | while command2 != "5": 139 | print("Please write command!") 140 | print("1 to publish new post") 141 | print("2 to get posts") 142 | print("3 to get app name") 143 | print("4 to sign up") 144 | print("5 to Exit") 145 | print() 146 | command2 = input() 147 | if command2 == "1": 148 | Insta.publish_new_post() 149 | if command2 == "2": 150 | Insta.get_posts() 151 | if command2 == "3": 152 | print(Insta.get_name()) 153 | if command2 == "4": 154 | Insta.sign_up() 155 | if command2 == "5": 156 | command2 = "0" 157 | break 158 | if command == "2": 159 | while command3 != "5": 160 | print("Please write command!") 161 | print("1 to create new tweet") 162 | print("2 to get tweets") 163 | print("3 to get app name") 164 | print("4 to sign up") 165 | print("5 to Exit") 166 | print() 167 | command3 = input() 168 | if command3 == "1": 169 | Twit.create_new_tweet() 170 | if command3 == "2": 171 | Twit.get_tweets() 172 | if command3 == "3": 173 | print(Twit.get_name()) 174 | if command3 == "4": 175 | Twit.sign_up() 176 | if command3 == "5": 177 | command3 = "0" 178 | break 179 | -------------------------------------------------------------------------------- /pictures/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsadiAhmad/Data-Base-Assignment-3/1e737c5fd3ce586d39ab536c4970570ca0173881/pictures/1.png -------------------------------------------------------------------------------- /pictures/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsadiAhmad/Data-Base-Assignment-3/1e737c5fd3ce586d39ab536c4970570ca0173881/pictures/2.png -------------------------------------------------------------------------------- /pictures/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsadiAhmad/Data-Base-Assignment-3/1e737c5fd3ce586d39ab536c4970570ca0173881/pictures/3.png -------------------------------------------------------------------------------- /pictures/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsadiAhmad/Data-Base-Assignment-3/1e737c5fd3ce586d39ab536c4970570ca0173881/pictures/4.png -------------------------------------------------------------------------------- /pictures/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsadiAhmad/Data-Base-Assignment-3/1e737c5fd3ce586d39ab536c4970570ca0173881/pictures/5.png -------------------------------------------------------------------------------- /pictures/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsadiAhmad/Data-Base-Assignment-3/1e737c5fd3ce586d39ab536c4970570ca0173881/pictures/6.png -------------------------------------------------------------------------------- /pictures/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsadiAhmad/Data-Base-Assignment-3/1e737c5fd3ce586d39ab536c4970570ca0173881/pictures/7.png --------------------------------------------------------------------------------