-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.java
More file actions
105 lines (95 loc) · 1.95 KB
/
Copy pathProduct.java
File metadata and controls
105 lines (95 loc) · 1.95 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
* Product class
*
* @author jusps
* @version 1
*/
public abstract class Product implements Comparable {
private String name = "";
private String description = "";
private int stock = 0;
int price = 2;
/**
* constructor for the product object
*
* @param String name
* @param String description
*/
public Product(String name, String description) {
this.name = name;
this.description = description;
}
/**
* getter for the name
*
* @return String name
*/
public String getName() {
return name;
}
/**
* getter for the description
*
* @return String description
*/
public String getDescription() {
return description;
}
/**
* getter for the stock
*
* @return int stock
*/
public int getStock() {
return stock;
}
/**
* getter for the price
*
* @return int price
*/
public int getPrice() {
return price;
}
/**
* setter for the name
*
* @param String name
*/
public void setName(String name) {
this.name = name;
}
/**
* setter for the description
*
* @param String description
*/
public void setDescription(String desc) {
description = desc;
}
/**
* mutator to add stock, adding the number provided
*
* @param int add
*/
public void addStock(int add) {
stock += add;
}
/**
* setter to set the price
*
* @param int nuPrice
*/
public void setPrice(int nuPric) {
price = nuPric;
}
/**
* compares the prices to see which one is superior
* (positive if this is bigger than the other one)
*
* @param int nuPrice
*/
public int compareTo(Object otherProduct) {
return price - ((Product)otherProduct).getPrice();
}
}