-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProducts.java
More file actions
88 lines (77 loc) · 2.93 KB
/
Products.java
File metadata and controls
88 lines (77 loc) · 2.93 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
package oop;
public class Products {
private String productName;
private String productColor;
private String category;
private int stock;
private double productWeight;
private String descriptionInformation;
//CONSTRUCTOR FOR PRODUCTS CLASS
public Products(String productName,String productColor,String category, int stock, double productWeight, String descriptionInformation){
this.productName=productName;
this.productColor=productColor;
this.category=category;
this.stock=stock;
this.productWeight=productWeight;
this.descriptionInformation=descriptionInformation;
}
//GETTER AND SETTER METHODS OF PRODUCTS CLASS
public void setProductName(String productName){
this.productName=productName;
}
public String getProductName() {
return this.productName;
}
public void setProductColor(String productColor){
this.productColor=productColor;
}
public String getProductColor(){
return this.productColor;
}
public void setCategory(String category){
this.category=category;
}
public String getCategory(){
return this.category;
}
public void setStock(int stockInformation) {
this.stock = stock;
}
public int getStock() {
return this.stock;
}
public void setProductWeight(double productWeight) {
this.productWeight = productWeight;
}
public double getProductWeight() {
return this.productWeight;
}
public void setDescriptionInformation(String descriptionInformation) {
this.descriptionInformation = descriptionInformation;
}
public String getDescriptionInformation() {
return this.descriptionInformation;
}
public void stockStatus(int quantity){ //Reduces the number of Stocks and control the stock number
if( quantity>0 && this.stock>=quantity && this.stock>0){
System.out.println(getProductName()+"Purchase completed succesfully.");
this.stock-=quantity;
System.out.println("Number of products remaining in stock:"+this.stock);
} else if (this.stock==0) {
System.out.println(getProductName()+ "Out of stock...");
}
else {
System.out.println("The quantity must be a positive integer.");
}
}
public void ProductInformation(){
System.out.println("---------Product Informations---------");
System.out.println();
System.out.println("Product Name :" +this.productName);
System.out.println("Product Color :" +this.productColor);
System.out.println("Category of Product :" +this.category);
System.out.println("Stock Status of Product:" +this.stock);
System.out.println("Product Weight: " + this.productWeight);
System.out.println("Description Information of Product :" +this.descriptionInformation);
}
}