Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: UTF8 -*-
- #-------------------------------------------------------------------------------
- # Author : Oluwaseun Peter
- # Copyright : Copyright (C) 2018
- # Target : All platforms supporting python
- # Limitations : None known as of now
- #-------------------------------------------------------------------------------
- class Library:
- def __init__(self, books=[]):
- self._id = 0
- self._catalog = books
- self._book_name = ''
- def display_avail_book(self):
- pass
- def borrow_out_book(self, title):
- pass
- def add_borrowed_book(self, title):
- pass
- class User:
- def __init__(self):
- self._name = ''
- self.database = {}
- self._id = 0
- def _increment_id(self):
- self._id += 1
- return self._id
- def _find_error(self, username, password):
- if not username.isspace() or username == '':
- if username in self.database.keys():
- print('The username: "{}" you chose is already registered with us. Please choose another one'.format(username))
- return True
- elif len(username) <= 3 or len(username) >= 15:
- print('The username you entered should be between 3 and 15 characters')
- return True
- elif username.isspace():
- print('Username field cannot be empty')
- return True
- elif password.isspace():
- print('Password cant be left blank')
- return True
- else:
- return False
- def _set_user_details(self, username):
- self.username = username.lower()
- #self.password = password
- def _signup(self, username, password):
- increment_user_id = self._increment_id()
- self.database[self.username] = {'user_id': increment_user_id, 'username': username, 'password': password}
- print('Success')
- def display_signup_form(self):
- username = input('Enter your username: ')
- password = input('Enter your password: ')
- find_error = self._find_error(username, password)
- if not find_error:
- self._set_user_details(username)
- self._signup(username, password)
- def show(self):
- print(self.database)
- class Menu:
- def display_menu(self):
- userMenu = ['Enter 1 to signup', 'Enter 2 login']
- print('\n'.join(userMenu))
- try:
- userChoice = int(input('Make your choice: '))
- if isinstance(userChoice, int):
- self.userChoice = userChoice
- except ValueError:
- print('Wrong input')
- else:
- return self.userChoice
- library = Library()
- access = User()
- usermenu = Menu()
- print('Welcome to my Second Project')
- print()
- print('-------------------------------')
- print('Title: Library System')
- print('Version: 1')
- print('-------------------------------')
- print()
- while True:
- userChoice = usermenu.display_menu()
- if userChoice == 1:
- signup_form = access.display_signup_form()
- if userChoice == 2:
- access.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement