-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathProduct.java
More file actions
48 lines (40 loc) · 945 Bytes
/
Product.java
File metadata and controls
48 lines (40 loc) · 945 Bytes
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
package com.collection;
public class Product implements Comparable<Product>{
private int productId;
private String productName;
private float price;
public Product(int productId, String productName, float price) {
super();
this.productId = productId;
this.productName = productName;
this.price = price;
}
public int getProductId() {
return productId;
}
public String getProductName() {
return productName;
}
public float getPrice() {
return price;
}
public String toString() {
return "Product [productId=" + productId + ", productName="
+ productName + ", price=" + price + "]";
}
/*public int compareTo(Object obj)
{
Product p = (Product)obj;
if(this.productId>(p.productId)){
return 1;
}
else if(this.productId<p.productId){
return -1;
}
return 0;*/
public int compareTo(Product p)
{
return p.productId - this.productId;
//return this.productId - p.productId;
}
}