Пример #1
0
#
# #uncomment below code to see how courses are removed from the student's course list
# for i in range(len(availableCourses)):
#     newStudent.removeCourse(availableCourses[i])
# newStudent.showInfo()
# print('\n\n')

# building a cart
courseCart = Cart()
# added all courses to cart
#there are 3 courses in the coursedata.py. There total cost is 80,000
for i in range(len(availableCourses)):
    courseCart.addItem(newStudent, availableCourses[i])

print('Current Courses in cart: ')
courseCart.displayCart()
print('Total course cost is{}'.format(courseCart.totalCourseCost()))

# to see the description of a course uncomment the corresponding line below
# courseCart.printItemInfo(courseCart.currentCartContent()[0]) # the first course
# courseCart.printItemInfo(courseCart.currentCartContent()[1]) # the second course
# courseCart.printItemInfo(courseCart.currentCartContent()[2]) # the third course

# below code removes all courses except the last one, i.e. OOPD
courseCart.removeItem(newStudent, availableCourses[0])
print('Current Courses in cart: ')
courseCart.displayCart()
print('Total course cost is{}'.format(courseCart.totalCourseCost()))

courseCart.removeItem(newStudent, availableCourses[1])
print('Current Courses in cart: ')
Пример #2
0
    def Sys():
        p = Product.productRepository()
        ct = Cart.createCart()
        try:
            ch1 = input("Do you wish to search Product(y/n): ")
            if ch1 == 'y':
                while ch1 == 'y':
                    s = Search.name(p)
                    Search.displayBrand(s)

                    if len(s) != 0:
                        b = Brand.chooseBrand()
                        o = Brand.selectBrand(b, s)
                        vo = Brand.verifyBrand(o)
                    else:
                        raise TypeError()

                    if len(vo) != 0:
                        q = Quantity.quantity()
                        vq = Quantity.verifyQuantity(q, vo)
                    else:
                        raise TypeError()

                    if vq == True:
                        pr = Price.calculateProductPrice(q, vo)
                        uo = Order.updateOrder(vo, q, pr)
                        act = Cart.addToCart(ct, uo)
                        #print(act)
                    else:
                        raise TypeError()

                    ch2 = input("Do you want to search again (y/n): ")
                    if ch2 == 'y':
                        pass
                    elif ch2 == 'n':
                        break
                    else:
                        raise TypeError()

                if len(act) != 0:
                    ch3 = input("Do you want to see your cart(y/n): ")
                    if ch3 == 'y':
                        Cart.displayCart(act)
                        if len(act) != 0:
                            while True:
                                ch4 = input(
                                    "Do you wish to remove Products from your cart(y/n): "
                                )
                                if ch4 == 'y':
                                    act = Cart.removeFromCart(act)
                                    Cart.displayCart(act)
                                elif ch4 == 'n':
                                    Order.placeOrder(act)
                                    break
                                else:
                                    raise ValueError()
                                    break

                    elif ch3 == 'n':
                        print("Thankyou for visiting")
                    else:
                        raise ValueError()
                else:
                    raise TypeError()

            elif ch1 == 'n':
                print("Thanks For Visiting")
            else:
                raise ValueError()

        except ValueError:
            print("Incorrect Choice")
        except TypeError:
            pass
        except UnboundLocalError:
            pass