-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.java
More file actions
27 lines (23 loc) · 823 Bytes
/
Copy pathProduct.java
File metadata and controls
27 lines (23 loc) · 823 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
public class Product {
private int id;
private String name;
private int quantity;
private double price;
public Product(int id, String name, int quantity, double price) {
this.id = id;
this.name = name;
this.quantity = quantity;
this.price = price;
}
public int getId() { return id; }
public String getName() { return name; }
public int getQuantity() { return quantity; }
public double getPrice() { return price; }
public void setQuantity(int quantity) { this.quantity = quantity; }
public void setPrice(double price) { this.price = price; }
@Override
public String toString() {
return String.format("ID: %d | Name: %s | Qty: %d | Price: %.2f",
id, name, quantity, price);
}
}