-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathItem.java
56 lines (55 loc) · 1.04 KB
/
Item.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
public class Item
{
private int quantity;
private Product product;
/*
* Item() - Contructs a Item object
* @param p - product object
* @param q - this is the quantity
*/
public Item(Product p, int q)
{
quantity = q;
product = p;
}
/**
* addQuant() - adds quantity of a product bu incrementing it
* @param q This is the amount of quantity that is being added
**/
public void addQuant(int q)
{
quantity += q;
}
/**
* setQuantity() - sets the quantity
* @param q This is the amount of quantity
**/
public void setQuantity(int q)
{
quantity = q;
}
/**
* getProduct() - gets the Prroduct
* @return product This is returns the product
**/
public Product getProduct()
{
return product;
}
/**
* getQuantity() - gets the quantity of the product
* @return quantity This return the quantity
**/
public int getQuantity()
{
return quantity;
}
/**
* toString() - return the name of product, price and quantity
* @return product, quantity
**/
public String toString()
{
return product.toString() + ", " + quantity;
}
}