ShoppingCart

ShoppingCart - / * / ShoppingCart.java / / Represents a...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// ********************************************************************** // ShoppingCart.java // // Represents a shopping cart as an array of items // ********************************************************************** import java.text.NumberFormat; public class ShoppingCart { private Item[] cart; // an array of Items private int itemCount; // total number of items in the cart private double totalPrice; // total price of items in the cart private int capacity; // current cart capacity // ----------------------------------------------------------- // Creates an empty shopping cart with a capacity of 5 items. // ----------------------------------------------------------- public ShoppingCart() { capacity = 5; itemCount = 0; totalPrice = 0.0; cart = new Item[capacity]; } // ------------------------------------------------------- // Adds an item to the shopping cart. // ------------------------------------------------------- public void addToCart(String itemName, double price, int quantity)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/22/2010 for the course CS 202 taught by Professor Fong during the Spring '10 term at SIU Carbondale.

Page1 / 2

ShoppingCart - / * / ShoppingCart.java / / Represents a...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online