-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.java
More file actions
67 lines (54 loc) · 1.73 KB
/
Product.java
File metadata and controls
67 lines (54 loc) · 1.73 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
public class Product {
// Private attributes to store product details
private String id;
private String name;
private String description;
private int quantity;
private float price;
// Constructor to initialize a Product object with given details
public Product(String id, String name, String description, int quantity, float price) {
this.id = id;
this.name = name;
this.description = description;
this.quantity = quantity;
this.price = price;
}
// Getter methods to retrieve product details
public String getId() {
return id;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public float getPrice() {
return price;
}
public int getQuantity() {
return quantity;
}
// Setter methods to update product details
public void setName(String name) {
this.name = name;
}
public void setDescription(String description) {
this.description = description;
}
public void setPrice(float price) {
this.price = price;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
// Method to display product info
public void showInfo(){
System.out.println("Product ID : " + id);
System.out.println("Product Name : " + name);
System.out.println("Description : " + description);
System.out.println("Quantity : " + quantity);
System.out.println("Price : " + price);
System.out.println("-----------------------------------------");
}
}