-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStock.java
More file actions
79 lines (59 loc) · 2.37 KB
/
Stock.java
File metadata and controls
79 lines (59 loc) · 2.37 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
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
public class Stock {
private int stockId;
private Product product;
private String engineNumber;
private LocalDateTime entryDateTime;
private LocalDateTime purchaseDateTime;
Stock(int stockId, Product product, String engineNumber, LocalDateTime entryDateTime, LocalDateTime purchaseDateTime){
this.stockId = stockId;
this.product = product;
this.engineNumber = engineNumber;
this.entryDateTime = entryDateTime;
this.purchaseDateTime = purchaseDateTime;
}
public String toCsvRow(){
return stockId + ";" + product.productId + ";" + engineNumber + ";" + entryDateTime + ";" + purchaseDateTime + "\n";
}
public String toMenuOption(){
return stockId + " | " + product.brand + " | " + product.model + " | " + engineNumber + " | " + getMenuEntryDateTime() + " | " + getMenuPurchaseDateTime();
}
public Product getProduct(){
return product;
}
public void setProduct(Product newProduct){
product = newProduct;
}
public int getStockId(){
return stockId;
}
public String getEngineNumber(){
return engineNumber;
}
public void setEngineNumber(String newEngineNumber){
engineNumber = newEngineNumber;
}
public LocalDate getEntryDate(){
return entryDateTime == null ? null : entryDateTime.toLocalDate();
}
public LocalDate getPurchaseDate(){
return purchaseDateTime == null ? null : purchaseDateTime.toLocalDate();
}
public LocalDateTime getEntryDateTime(){
return entryDateTime == null ? null : entryDateTime;
}
public LocalDateTime getPurchaseDateTime(){
return purchaseDateTime == null ? null : purchaseDateTime;
}
public void setPurchaseDateTime(LocalDateTime newPurchaseDateTime){
purchaseDateTime = newPurchaseDateTime;
}
public String getMenuEntryDateTime(){
return entryDateTime == null ? "null" : entryDateTime.toLocalDate() + " " + entryDateTime.toLocalTime().truncatedTo(ChronoUnit.SECONDS);
}
public String getMenuPurchaseDateTime(){
return purchaseDateTime == null ? "null" : purchaseDateTime.toLocalDate() + " " + purchaseDateTime.toLocalTime().truncatedTo(ChronoUnit.SECONDS);
}
}