Week 6 Java Project LineItem.java



/**
 *
 * @author AMARE
 */
public class LineItem 

{
    private String itemName//Holds item name.


    private int quantity;  //Holds quantity of the item.


    private double price;   // Holds price of the item.

/**
 * The parameterized constructor accepts arguments
 * @param itemName
 * @param quantity
 * @param price 
 */
    public LineItem(String itemNameint quantitydouble price
    {
        this.itemName = itemName;
        this.setQuantity(quantity);
        this.setPrice(price);
    }
/**
 * The no arguments constructors method returns item name
 * @return 
 */

    public String getName() 
    {
        return this.itemName;
    }
/** 
 * The no argument constructors method returns item quantity
 * @return 
 */

    public int getQuantity() 
    {
        return quantity;
    }

/**
 * The parameterized arguments set quantity
 * @param quantity 
 */ 
    public void setQuantity(int quantity
    {
        this.quantity = quantity;
    }

/**
 * The no arguments constructor returns price of the item
 * @return 
 */ 
    public double getPrice()
     {
        return price;
    }

/**
 * The parameterized argument sets price
 * @param price 
 */ 
    public void setPrice(double price)
     {
        this.price = price;
    }

/**
 * The no arguments constructor returns total price
 * @return 
 */ 
    public double getTotalPrice() 
    {
        return price * quantity;
    }
/**
 * The no arguments constructor returns the strings
 * @return 
 */
    public String toString() 
    {
        return itemName + "\tqty " + quantity + "\t@ $" + price + "\t$"
                + getTotalPrice();
    }

Comments

Popular posts from this blog

Nаturаl Resource Conservаtion аnd Environmentаl Protection of the Nile River

Assignment 3: Apple versus Samsung

Week 8 Java Project [AmusementPark.java]