-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.java
More file actions
54 lines (49 loc) · 1.22 KB
/
Product.java
File metadata and controls
54 lines (49 loc) · 1.22 KB
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
/**
* A class that models a product.
* But Dan, why is Product abstract? It has no abstract methods!
* It is abstract because we shouldn't be able to make instances of it.
* The type is not complete.
* @author Liam O'Reilly
*
*/
public abstract class Product {
protected double price;
protected int numStock;
/**
* Create a new product.
* @param price The price of the product in pounds.
* @param numStock The amount of the product in stock.
*/
public Product(double price, int numStock) {
this.price = price;
this.numStock = numStock;
}
/**
* Get the price of the product.
* @return The price of the product in pounds.
*/
public double getPrice() {
return price;
}
/**
* Set the price of the product.
* @param price The price of the product in pounds.
*/
public void setPrice(double price) {
this.price = price;
}
/**
* Get the amount of product in stock.
* @return The amount of product in stock.
*/
public int getNumStock() {
return numStock;
}
/**
* Set the amount of product in stock.
* @param numStock The amount of product in stock.
*/
public void setNumStock(int numStock) {
this.numStock = numStock;
}
}