-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.java
More file actions
135 lines (102 loc) · 3.4 KB
/
Product.java
File metadata and controls
135 lines (102 loc) · 3.4 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
134
135
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package oopProject;
/**
*
* @author Melda
*/
public class Product {
private String productName;
private String colour;
private String category;
private String size;
private int numberOfStocks;
private double weight;
private String descriptionInf;
private double price;
public Product(String productName, String colour, String category, String size, int numberOfStocks,double weight, String descriptionInf, double price){
this.productName = productName;
this.colour = colour;
this.category = category;
this.size = size;
this.numberOfStocks = numberOfStocks;
this.weight = weight;
this.descriptionInf = descriptionInf;
this.price = price;
writeAllAtts();
}
public String getProductName() {
return productName;
}
public String getColour() {
return colour;
}
public String getCategory() {
return category;
}
public String getSize() {
return size;
}
public int getNumberOfStocks() {
return numberOfStocks;
}
public double getWeight() {
return weight;
}
public String getDescriptionInf() {
return descriptionInf;
}
public double getPrice(){
return price;
}
public void setProductName(String productName) {
this.productName = productName;
}
public void setColour(String colour) {
this.colour = colour;
}
public void setCategory(String category) {
this.category = category;
}
public void setSize(String size) {
this.size = size;
}
public void setNumberOfStocks(int numberOfStocks) {
this.numberOfStocks = numberOfStocks;
}
public void setWeight(double weight) {
this.weight = weight;
}
public void setDescriptionInf(String descriptionInf) {
this.descriptionInf = descriptionInf;
}
public void setPrice(double price){
this.price = price;
}
public void writeAllAtts(){
System.out.println("Product Name: " + getProductName());
System.out.println("Colour: " + getColour());
System.out.println("Category: " + getCategory());
System.out.println("Weight: " + getWeight());
System.out.println("Size: " + getSize());
System.out.println("Description Information: " + getDescriptionInf());
System.out.println("Price: " + getPrice() + " TL");
System.out.println("\n\n");
}
public int reduceStocks(User user){
if(getNumberOfStocks()>= user.getQuantity()){
setNumberOfStocks(getNumberOfStocks() - user.getQuantity());
}
else{
System.out.println();
System.out.println("There is not enough stock. This order cannot be fulfilled. ");
}
return getNumberOfStocks();
}
public void queryingNumberOfStocks(){
System.out.println();
System.out.println(getProductName()+" has "+ getNumberOfStocks()+" stocks now");
}
}