-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProduct.java
More file actions
75 lines (68 loc) · 3.33 KB
/
Copy pathProduct.java
File metadata and controls
75 lines (68 loc) · 3.33 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
public class Product {
private int productId;
private String name;
private String description;
private double price;
private double originalPrice;
private int categoryId;
private String categoryName;
private String brand;
private double rating;
private int reviewCount;
private int stock;
private String emoji;
private double trendingScore;
private double similarityScore; // used when shown as recommendation
public Product() {}
public Product(int productId, String name, double price, double originalPrice,
String brand, double rating, int reviewCount, String emoji, String categoryName) {
this.productId = productId;
this.name = name;
this.price = price;
this.originalPrice = originalPrice;
this.brand = brand;
this.rating = rating;
this.reviewCount = reviewCount;
this.emoji = emoji;
this.categoryName = categoryName;
}
public int getDiscountPercent() {
if (originalPrice > price) {
return (int) (((originalPrice - price) / originalPrice) * 100);
}
return 0;
}
public String getFormattedPrice() { return "₹" + String.format("%,.0f", price); }
public String getFormattedOriginal() { return "₹" + String.format("%,.0f", originalPrice); }
// ── Getters & Setters ──────────────────────────────────────────────────────
public int getProductId() { return productId; }
public void setProductId(int v) { this.productId = v; }
public String getName() { return name; }
public void setName(String v) { this.name = v; }
public String getDescription() { return description; }
public void setDescription(String v){ this.description = v; }
public double getPrice() { return price; }
public void setPrice(double v) { this.price = v; }
public double getOriginalPrice() { return originalPrice; }
public void setOriginalPrice(double v){ this.originalPrice = v; }
public int getCategoryId() { return categoryId; }
public void setCategoryId(int v) { this.categoryId = v; }
public String getCategoryName() { return categoryName; }
public void setCategoryName(String v){ this.categoryName = v; }
public String getBrand() { return brand; }
public void setBrand(String v) { this.brand = v; }
public double getRating() { return rating; }
public void setRating(double v) { this.rating = v; }
public int getReviewCount() { return reviewCount; }
public void setReviewCount(int v) { this.reviewCount = v; }
public int getStock() { return stock; }
public void setStock(int v) { this.stock = v; }
public String getEmoji() { return emoji; }
public void setEmoji(String v) { this.emoji = v; }
public double getTrendingScore() { return trendingScore; }
public void setTrendingScore(double v){ this.trendingScore = v; }
public double getSimilarityScore() { return similarityScore; }
public void setSimilarityScore(double v){ this.similarityScore = v; }
@Override
public String toString() { return name + " (" + brand + ")"; }
}