Beruflich Dokumente
Kultur Dokumente
Problem Description:
This project provides the software for online shopping. The purpose of this project is to provide
an easy shopping facility online and easy selling facility to the merchants of all categories. The
customers register with their details and get authentication for an authorized Login.The software
provides free shipping to the customers, and provide the product information to the customers and
up to date information on the product
Implementation Details:
Class: Customer
Add code to Customer based on the class diagram and the additional implementation details are given
below.
Constructor
Customername :
Customer address:
Customer E-mail:
Creditcard info :
it retuns the creditcard Number,Name of the customer,CVV Number and PIN Number
Shopping info:
It returns the Product information,Price of the Product,and confirmation of the product to be displayed
Column Name Type Size Description
Customeraddress varchar 50
Class: Address
Add code to Address based on the class diagram. Wherever needed, the additional implementation
details are given below.
Constructor:
Use parameterized constructor to initialize addressline, city, pincode and state. Auto-generated number
must be given for addressid.
validatepincode ():
This method validates the pincode member variable and returns a boolean value
This method returns true if the value of pincode is valid, otherwise it must return false
class Item(object):
def __init__(self,itemname,itemprice):
self.__itemname = itemname
self.__itemprice = itemprice
def GetItemName(self):
return self.__itemname
def GetItemPrice(self):
return self.__itemprice
def ChangeItemPrice(self,newprcie):
self.__itemprice = newprice
def ShowCart(self):
return self
class customerobject):
self.name = name
self.__cartlist = {}
self.__cartlist[0] = Cart()
def AddCart(self):
self.__cartlist[len(self.__cartlist)] = Cart()
return self.__cartlist[cartindex]
def BuyItem(self, item, itemnum, cartindex = 0):
try:
self.__cartlist[cartindex][item.GetItemName()][1] += itemnum
except:
self.__cartlist[cartindex].update({item.GetItemName():[item.GetItemPrice(),itemnum]})
pass
if __name__ == '__main__':
item2 = Item('pear', 5)
user1 = User('John')
user1.BuyItem(item1, 5)
user1.BuyItem(item2, 6)
user1.AddCart()
user1.BuyItem(item1, 5, 1)
class Item(object):
def __init__(self, name, price):
self.name = name
self.price = price
class Cart(dict):
try:
self[item.name][1] += amount
except IndexError:
self.update({
})
class User(object):
self.name = name
self.carts = [Cart()]
def add_cart(self):
self.carts.append(Cart())
self.carts[cart_index].add_item(item, amount)
def main():
john = User('John')
# I would choose `john.add_item(apple, 5, 1)`
# or `john.carts[0].add_item(apple, 5)`
# Not both.
john.add_item(apple, 5)
john.carts[0].add_item(Item('pear', 5), 6)
john.add_cart()
john.add_item(apple, 5, 1)
if __name__ == '__main__':
main()