-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.java
More file actions
133 lines (116 loc) · 2.86 KB
/
Copy pathProduct.java
File metadata and controls
133 lines (116 loc) · 2.86 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package naeemmohammadprogrammingckpt3;
/**
* this class represents as a parent class along with a Product object
*
* @author Mohammad Naeem
*/
public abstract class Product {
private String productName;
private int productID;
private double productCost;
private int numInStock;
/**
* it is a default constructor
*/
public Product() {
}
/**
* this constructor creates product object with product's: name, id, and
* cost
* @param productName
* @param productID
* @param productCost
* @param numInStock
*/
public Product(String productName, int productID, double productCost, int numInStock) {
this.productName = productName;
this.productID = productID;
this.productCost = productCost;
this.numInStock = numInStock;
}
/**
* gets name of the product
*
* @return productName
*/
public String getProductName() {
return productName;
}
/**
* gets id of product
*
* @return productID
*/
public int getProductID() {
return productID;
}
/**
* gets cost of product
*
* @return productCost
*/
public double getProductCost() {
return productCost;
}
/**
* gets quantity of in stock items
*
* @return numInStock
*/
public int getNumInStock() {
return numInStock;
}
/**
* updates quantity of in stock items
*
* @param numInStock
*/
public void setNumInStock(int numInStock) {
this.numInStock = numInStock;
}
/**
* sets name of the product
*
* @param productName
*/
public void setProductName(String productName) {
this.productName = productName;
}
/**
* sets the id of the product
*
* @param productID
*/
public void setProductID(int productID) {
this.productID = productID;
}
/**
* sets product cost
*
* @param productCost
*/
public void setProductCost(double productCost) {
this.productCost = productCost;
}
/**
* this method demonstrates a decrement by value of 1 in stocked items' quantity after purchase(s).
*/
public void decreaseNumInStock() {
numInStock--;
}
/**
* displays product: name, id, and Price as a super display in sub classes
* along with the product: name, id, and price.
*/
public void display() {
System.out.println("Name: " + this.getProductName()
+ " ID: " + this.getProductID()
+ " Price: $" + this.getProductCost()
+ " Items in stock: " + this.getNumInStock());
}
}