Giter Site home page Giter Site logo

oop_mall's Introduction

Mall Object-Oriented Programming Project ๐Ÿ›’

This is a simple Mall project implemented using Object-Oriented Programming principles, including three classes: Item, Cart, and Customer.

Classes

Item

The Item class represents an item in the mall. It has the following attributes:

name: A string representing the name of the item. price: A float representing the price of the item.

Cart

The Cart class represents a shopping cart in the mall. It has the following attributes:

items: A list of Item objects representing the items in the cart. customer: A Customer object representing the customer who owns the cart. It also has the following methods:

add_item(item): Adds an Item object to the cart. remove_item(item): Removes an Item object from the cart. total_cost(): Calculates and returns the total cost of all the items in the cart.

Customer

The Customer class represents a customer in the mall. It has the following attributes:

name: A string representing the name of the customer. age: An integer representing the age of the customer.

Example Usage

Here is an example of how to use these classes together:

# Create some items
item1 = Item("Shirt", 29.99, 2)
item2 = Item("Jeans", 39.99, 3)
item3 = Item("Shoes", 49.99, 1)

# Create a customer
customer = Customer("John", 25)

# Create a cart for the customer and add some items
cart = Cart(customer)
cart.add_item(item1)
cart.add_item(item2)

# Calculate the total cost of the cart
total_cost = cart.total_cost()

# Remove an item from the cart
cart.remove_item(item2)

# Calculate the total cost of the cart again
total_cost = cart.total_cost()

Conclusion This is a simple implementation of a Mall project using Object-Oriented Programming principles. The Item, Cart, and Customer classes can be used to represent a shopping experience in a mall.

oop_mall's People

Contributors

luigiremor avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.