Sie sind auf Seite 1von 9

ONLINE SHOPPING MANAGEMENT SYSTEMS

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

It initializes, customername,customeraddress, email.creditcardinfo,shoppinginfo and auto generates


customerid.

Customername :

Name of the customer

Customer address:

It returns the address of the custiomer

Customer E-mail:

It returns the valid email address of the customer

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

CustomerName Varchar 30 Primarykey

Customeraddress varchar 50

Customer E-mail varchar 30

Creditcardinfo Number,varchar 10,10

Shoppinginfo Varchar,number 10,10

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

pincode must be validated for 6 digits

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

class Cart(dict): #cart dict format: {itemname:[price,number]}

def ShowCart(self):

return self

class customerobject):

def __init__(self, name):

self.name = name

self.__cartlist = {}

self.__cartlist[0] = Cart()

def AddCart(self):

self.__cartlist[len(self.__cartlist)] = Cart()

def GetCart(self, cartindex = 0):

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]})

def BuyCancle(self, itemname, itemnum, cartindex = 0):

pass

if __name__ == '__main__':

item1 = Item('apple', 7.8)

item2 = Item('pear', 5)

user1 = User('John')

user1.BuyItem(item1, 5)

print("user1 cart0 have: %s" % user1.GetCart(0).ShowCart())

user1.BuyItem(item2, 6)

print("user1 cart0 have: %s" % user1.GetCart(0).ShowCart())

user1.AddCart()

user1.BuyItem(item1, 5, 1)

print("user1 cart1 have: %s" % user1.GetCart(1).ShowCart())

class Item(object):
def __init__(self, name, price):

self.name = name

self.price = price

class Cart(dict):

def add_item(self, item, amount):

try:

self[item.name][1] += amount

except IndexError:

self.update({

item.name: [item.price, amount]

})

class User(object):

def __init__(self, name):

self.name = name

self.carts = [Cart()]

def add_cart(self):

self.carts.append(Cart())

def add_item(self, item, amount, cart_index=0):

self.carts[cart_index].add_item(item, amount)

def main():

apple = Item('apple', 7.8)

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)

print("John's first cart has: {}".format(john.carts[0]))

john.carts[0].add_item(Item('pear', 5), 6)

print("John's first cart has: {}".format(john.carts[0]))

john.add_cart()

john.add_item(apple, 5, 1)

print("John's second cart has: {}".format(john.carts[1]))

if __name__ == '__main__':

main()

Das könnte Ihnen auch gefallen