Skip to content

A Java-based shopping cart system demonstrating OOP concepts like classes, arrays, and methods. It allows adding products, validating prices, displaying cart contents, and calculating the total cost, with basic error handling for full or empty cart scenarios.

Notifications You must be signed in to change notification settings

Rahmaeb/Shopping_Cart_System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Shopping Cart Project

This is a Java-based project that simulates a shopping cart system. The project demonstrates object-oriented programming concepts, including the use of classes, constructors, arrays, and methods. It also incorporates basic error handling and array operations.

Project Description

The project consists of the following components:

  1. Product Class:

    • Represents a product with attributes: id, description, price, and quantity.
    • Includes a constructor to initialize the attributes.
    • Provides a method displayProductInfo() to display product details.
  2. ShoppingCart Class:

    • Manages a collection of products using an array with a fixed size of 5.
    • Includes methods to:
      • Add a product to the cart (addProductToCart(Product product)), ensuring valid input.
      • Calculate the total cost of products in the cart (calculateTotalCost()).
      • Display the contents of the cart (displayCartContents()).
  3. Main Class:

    • Demonstrates the functionality of the Product and ShoppingCart classes.
    • Instantiates three products and adds them to the shopping cart.
    • Displays the cart contents and calculates the total cost.

Features

  • Add products to the shopping cart.
  • Validate product price before adding.
  • Display product details and cart contents.
  • Calculate and display the total cost of the products in the cart.
  • Handles scenarios like full cart and empty cart.

About

A Java-based shopping cart system demonstrating OOP concepts like classes, arrays, and methods. It allows adding products, validating prices, displaying cart contents, and calculating the total cost, with basic error handling for full or empty cart scenarios.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages