2
Contributors
3
Replies
17
Views
2 Years
Discussion Span
Last Post by Andrae
0

What your asking sound a lot like what Im making right now. here is what I have so far...

Note: If you run the program you will have to make some .txt file and change the directories.

import time

i = ""
fileContents = ""
#User 1
password1 = "hellomynameis"
username1 = "DragonMastur"
#User 2
password2 = "michael"
username2 = "aiden"
#User 3
password3 = "..........."
username3 = "..........."

line = "A line looks."

class Book:
    def readBook(self, line):
        print "Fetching Book..."
        file = open('/home/pi/BookFolder/book.txt', mode='r')
        time.sleep(1)
        print "Done"
        time.sleep(1)
        print "\n\n\n"
        while line != "":
            line = str(file.readline())
            print line
        print "\n\n\n"

    def readBook2(self, line):
        print "Fetching Book..."
        file = open('/home/pi/BookFolder/book2.txt', mode='r')
        time.sleep(1)
        print "Done"
        time.sleep(1)
        print "\n\n\n"
        while line != "":
            line = str(file.readline())
            print line
        print "\n\n\n"

    def readBook3(self, line):
        print "Fetching Book..."
        file = open('/home/pi/BookFolder/book3.txt', mode='r')
        time.sleep(1)
        print "Done"
        time.sleep(1)
        print "\n\n\n"
        while line != "":
            line = str(file.readline())
            print line
        print "\n\n\n"

    def __init__(self):
        i = "Input from the user."
        while True:
            print 'Enter Your Username: '
            u = raw_input()
            if u == username1 or u == username2 or u == username3:
                print "Enter Your Password: "
                p = raw_input()
                if p == password1 and u == username1 or p == password2
and u == username2 or p == password3 and u == username3:
                    while i != "q" or i != "Q":
                        print "-------Menu-------"
                        print "Look at book     1"
                        print "Quit             Q"
                        i = raw_input()
                        if i == "1":
                            if u == username1:
                                self.readBook(line)
                            elif u == username2:
                                self.readBook2(line)
                            elif u == username3:
                                self.readBook3(line)
                            else:
                                print "ERORR!!!!!!!!!!!!"
                        elif i == "q" or i == "Q":
                            quit(0)
                        else:
                            print "Sorry...That is not Avalible."
                else:
                    print "Incorrect password."
                    print "Q = Quit\nP = Try again."
                    i = raw_input()
                    if  i == "q" or i == "Q":
                            quit(0)
                    elif i != "P" or i != "p":
                        print "Sorry not avalible... Quiting..."
                        time.sleep(5)
                        quit(0)
            else:
                print "Incorrect Username."
                print "Q = Quit\nU = Try again."
                i = raw_input()
                if i == "q" or i == "Q":
                    quit(0)
                elif i != "u" or i != "U":
                    print "Sorry not avalible... Quiting..."
                    time.sleep(5)
                    quit(0)
                elif i == "u" or i == "U":
                    pass


if __name__ == "__main__":
    Book()
    print "Good Bye! See you later!"
    time.sleep(5)
0

Thank you for sharing that code you gave me an idea of what i can do.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.