Exemple #1
0
                         "n: no\n")

        elif query == 3:
            account1.enquiry()
            cont = input("Do you want to do another operation?\n"
                         "y: yes\n"
                         "n: no\n")

        elif query == 4:
            account1.c_transfer()
            cont = input("Do you want to do another operation?\n"
                         "y: yes\n"
                         "n: no\n")

        elif query == 5:
            account1.buy()
            cont = input("Do you want to do another operation?\n"
                         "y: yes\n"
                         "n: no\n")

        elif query == 6:
            account1.payment()
            cont = input("Do you want to do another operation?\n"
                         "y: yes\n"
                         "n: no\n")

        elif query == 7:
            account1.create_account()
            cont = input("Do you want to do another operation?\n"
                         "y: yes\n"
                         "n: no\n")
def main():
    """ The main function """

    # Create two manufacturers and add models of bike
    pinarello = Manufacturer("Pinarello", 0.3)
    pinarello.add_model("TimeAttack", CarbonFrame, TimeTrialWheel)
    pinarello.add_model("RoadWarrior", AluminiumFrame, RoadWheel)
    pinarello.add_model("SanRemo", CarbonFrame, RoadWheel)

    trek = Manufacturer("Trek", 0.3)
    trek.add_model("MountainHawg", SteelFrame, MountainBikeWheel)
    trek.add_model("Rodeo", SteelFrame, RoadWheel)
    trek.add_model("Everest", CarbonFrame, MountainBikeWheel)

    # Create a shop which stocks products from both manufacturers
    bobs_cycles = Shop("Bob's Cycles", 0.2)
    bobs_cycles.add_manufacturer(pinarello)
    bobs_cycles.add_manufacturer(trek)

    # Buy 5 of each bike as stock
    for i in xrange(5):
        bobs_cycles.buy("Pinarello", "TimeAttack")
        bobs_cycles.buy("Pinarello", "RoadWarrior")
        bobs_cycles.buy("Pinarello", "SanRemo")

        bobs_cycles.buy("Trek", "MountainHawg")
        bobs_cycles.buy("Trek", "Rodeo")
        bobs_cycles.buy("Trek", "Everest")

    # Create three customers with different budgets
    alice = Customer("Alice", 200)
    dan = Customer("Dan", 500)
    carol = Customer("Carol", 1000)

    customers = (alice, dan, carol)

    # Print the weight of the bikes sold by Bob's Cycles
    print "Bicycle weights:"
    print ""
    for bike_specification in bobs_cycles.product_range():
        print "{:40} {}kg".format(bike_specification.full_name(),
                                  bike_specification.weight)
    print ""

    # Print the bikes which each customer can afford
    print "Customers:"
    print ""
    for customer in customers:
        print "{} can afford the following bikes:".format(customer.name)
        print ""
        for bike_specification in bobs_cycles.product_range():
            price = bobs_cycles.price(bike_specification.manufacturer_name,
                                      bike_specification.name)
            if price > customer.money:
                continue

            print bike_specification.full_name()
        print ""

    # Print the current stock levels at Bob's Cycles
    print "Inventory of Bob's Cycles: "
    print ""
    for bike_specification in bobs_cycles.product_range():
        stock = bobs_cycles.stock(bike_specification.manufacturer_name,
                                  bike_specification.name)
        print "{:40} {} in stock".format(bike_specification.full_name(), stock)

    # Buy a bike for each customer
    alice.buy(bobs_cycles, "Trek", "MountainHawg")
    dan.buy(bobs_cycles, "Trek", "MountainHawg")
    carol.buy(bobs_cycles, "Pinarello", "SanRemo")
    print ""

    # Print the customer's purchases, and remaining money
    for customer in customers:
        print "{} now owns a {}".format(customer.name,
                                        customer.bike.full_name())
        print "{} has ${:.2f} remaining".format(customer.name, customer.money)
        print ""


    # Print the updates stock levels
    print "Updated inventory of Bob's Cycles: "
    print ""
    for bike_specification in bobs_cycles.product_range():
        stock = bobs_cycles.stock(bike_specification.manufacturer_name,
                                  bike_specification.name)
        print "{:40} {} in stock".format(bike_specification.full_name(), stock)

    print ""

    # Print the amount of profit Bob has made
    print "Profit for Bob's Cycles: ${}".format(bobs_cycles.profit)
def customer_menu():
    # ---------------customer menu ----------------------
    while True:
        try:
            customer_choice = input("""
                                      A: Show all products
                                      B: Buy new product
                                      C: Final factor
                                      D: Change password
                                      Q: Logout

                                      Please enter your choice: """)
        except ArithmeticError:
            print('invalid input,enter your choice.\n')
            all_loggers.error("Exception occured, user enter invalid input",
                              exc_info=True)
        except ValueError:
            print('invalid input,enter "A" or "B".\n')
            all_loggers.error(
                "Exception occured, user enter invalid input in menu",
                exc_info=True)
        except TypeError:
            print("enter suitable input")
            all_loggers.error("Exception occured, user enter invalid input",
                              exc_info=True)

        else:
            if customer_choice == "a" or customer_choice == "A":
                Products.show_products()
            elif customer_choice == "b" or customer_choice == "B":
                # ------------select the product from list of products name---------

                pd_products = pd.read_csv('Products.csv')
                products_names = list(pd_products['name'])
                print(products_names)
                for product in range(len(products_names)):
                    """
                    customer can buy anything he/she want
                    """
                    try:
                        user_choice = input("what do you want to buy?")
                        customer_amount = int(
                            input(f"how many {user_choice} do you want"))

                        kala = Customer.buy(user_choice, customer_amount)
                        ques = input("do you want to conteniue?")
                        if ques == "NO" or ques == "no" or ques == "No":
                            break
                        elif ques == "yes" or ques == "Yes" or ques == "YES":
                            continue

                        if kala == True:
                            print("congratulation, you buy it successfully ")
                        elif kala == False:
                            print("sorry, try again")

                    except ArithmeticError:
                        print('invalid input,enter currect input.\n')
                        all_loggers.error(
                            "Exception occured, user enter invalid input",
                            exc_info=True)
                    except ValueError:
                        print('invalid input,enter a number.\n')
                        all_loggers.error(
                            "Exception occured, user enter invalid input",
                            exc_info=True)
                    except TypeError:
                        print("enter suitable input")
                        all_loggers.error("TypeError", exc_info=True)

            elif customer_choice == "c" or customer_choice == "C":
                Customer.see_factor()
            elif customer_choice == "d" or customer_choice == "D":
                try:
                    username = input("please enter your username: "******"enter your old password")
                    new_password = input("what is new password:"******"enter suitable input")

            elif customer_choice == "Q" or customer_choice == "q":
                break
Exemple #4
0
from customer import Customer
from student import Student

customer1 = Customer('Gabriel', 23)
customer1.speak()
customer1.buy()

student1 = Student('Maria', 32)
student1.speak()
student1.study()
Exemple #5
0
def main():
    """ The main function """

    # Create two manufacturers and add models of bike
    pinarello = Manufacturer("Pinarello", 0.3)
    pinarello.add_model("TimeAttack", CarbonFrame, TimeTrialWheel)
    pinarello.add_model("RoadWarrior", AluminiumFrame, RoadWheel)
    pinarello.add_model("SanRemo", CarbonFrame, RoadWheel)

    trek = Manufacturer("Trek", 0.3)
    trek.add_model("MountainHawg", SteelFrame, MountainBikeWheel)
    trek.add_model("Rodeo", SteelFrame, RoadWheel)
    trek.add_model("Everest", CarbonFrame, MountainBikeWheel)

    # Create a shop which stocks products from both manufacturers
    bobs_cycles = Shop("Bob's Cycles", 0.2)
    bobs_cycles.add_manufacturer(pinarello)
    bobs_cycles.add_manufacturer(trek)

    # Buy 5 of each bike as stock
    for i in xrange(5):
        bobs_cycles.buy("Pinarello", "TimeAttack")
        bobs_cycles.buy("Pinarello", "RoadWarrior")
        bobs_cycles.buy("Pinarello", "SanRemo")

        bobs_cycles.buy("Trek", "MountainHawg")
        bobs_cycles.buy("Trek", "Rodeo")
        bobs_cycles.buy("Trek", "Everest")

    # Create three customers with different budgets
    alice = Customer("Alice", 200)
    dan = Customer("Dan", 500)
    carol = Customer("Carol", 1000)

    customers = (alice, dan, carol)

    # Print the weight of the bikes sold by Bob's Cycles
    print "Bicycle weights:"
    print ""
    for bike_specification in bobs_cycles.product_range():
        print "{:40} {}kg".format(bike_specification.full_name(),
                                  bike_specification.weight)
    print ""

    # Print the bikes which each customer can afford
    print "Customers:"
    print ""
    for customer in customers:
        print "{} can afford the following bikes:".format(customer.name)
        print ""
        for bike_specification in bobs_cycles.product_range():
            price = bobs_cycles.price(bike_specification.manufacturer_name,
                                      bike_specification.name)
            if price > customer.money:
                continue

            print bike_specification.full_name()
        print ""

    # Print the current stock levels at Bob's Cycles
    print "Inventory of Bob's Cycles: "
    print ""
    for bike_specification in bobs_cycles.product_range():
        stock = bobs_cycles.stock(bike_specification.manufacturer_name,
                                  bike_specification.name)
        print "{:40} {} in stock".format(bike_specification.full_name(), stock)

    # Buy a bike for each customer
    alice.buy(bobs_cycles, "Trek", "MountainHawg")
    dan.buy(bobs_cycles, "Trek", "MountainHawg")
    carol.buy(bobs_cycles, "Pinarello", "SanRemo")
    print ""

    # Print the customer's purchases, and remaining money
    for customer in customers:
        print "{} now owns a {}".format(customer.name,
                                        customer.bike.full_name())
        print "{} has ${:.2f} remaining".format(customer.name, customer.money)
        print ""

    # Print the updates stock levels
    print "Updated inventory of Bob's Cycles: "
    print ""
    for bike_specification in bobs_cycles.product_range():
        stock = bobs_cycles.stock(bike_specification.manufacturer_name,
                                  bike_specification.name)
        print "{:40} {} in stock".format(bike_specification.full_name(), stock)

    print ""

    # Print the amount of profit Bob has made
    print "Profit for Bob's Cycles: ${}".format(bobs_cycles.profit)
Exemple #6
0
bike1 = Bicycle("VN1", frame = frame1, wheel = wheel1)   
bike2 = Bicycle("VN2", frame = frame1, wheel = wheel2)
bike3 =Bicycle("CN1", frame = frame1, wheel = wheel3)
bike4 =Bicycle("CN2", frame = frame2, wheel = wheel1)
bike5 =Bicycle("US1", frame = frame2, wheel = wheel2)
bike6 =Bicycle("US2", frame = frame2, wheel = wheel3) 
inventory = OrderedDict()
inventory[bike1] = 6
inventory[bike2] = 5
inventory[bike3] = 3
inventory[bike4] = 3
shop1 = Shop(sname = "Saigon", inventory = inventory, margin = 0.2)
shop1.add(bike3)
shop1.add({bike5: 2, bike6: 1})
pp1 = Customer("Khoe", 200)
pp2 = Customer("Tri", 500)
pp3 = Customer("Hung", 1000)

print(pp1.cname, "can buy", pp1.canbuy(shop1)) 
print(pp2.cname, "can buy", pp2.canbuy(shop1)) 
print(pp3.cname, "can buy", pp3.canbuy(shop1) )
shop1._show_inventory()
pp1.buy(shop1, bike1)
shop1.sell(bike1)
pp2.buy(shop1, bike2)
shop1.sell(bike2)
pp3.buy(shop1, bike3)
shop1.sell(bike3)


Exemple #7
0
from catalog import Catalog
from customer import Customer
#Функциите на Class "Stock" се демонстрират в началото на Class "Customer"
#За да може класа да използва параметрите на Class "Stock"

cat = Catalog()

c = Customer("Hristo", 30000, "Pig")
c.how_much_food_you_need(15, 30)
c.buy()
c = Customer("Petyr", 3000, "Pig")
c.how_much_food_you_need(3, 30)
c.buy()
c = Customer("Joro", 64510, "Horse")
c.how_much_food_you_need(5, 30)
c.buy()
c = Customer("Mitko", 25421, "Dog")
c.how_much_food_you_need(6, 30)
c.buy()