Copy of Snippet "newJava"

6th

import java.util.Date;
import java.util.Map;
public class Purchase {
//fill the code
private long id;
private Date purchaseDate;
private double totalAmount;
private String user;
public Purchase(long id, Date purchaseDate, double totalAmount, String user) {
super();
this.id = id;
this.purchaseDate = purchaseDate;
this.totalAmount = totalAmount;
this.user = user;
}
public Purchase() {
super();
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Date getPurchaseDate() {
return purchaseDate;
}
public void setPurchaseDate(Date purchaseDate) {
this.purchaseDate = purchaseDate;
}
public double getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(double totalAmount) {
this.totalAmount = totalAmount;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public static void obtainPurchaseWithItem(Map<String, Integer> map,String purchaseDetail) {
//fill the code
String arr[]=purchaseDetail.split(",");

for(Map.Entry<String, Integer> entryset:map.entrySet()) {
for(int i=3;i<arr.length;i=i+3) {
if(entryset.getKey().equals(arr[i])) {
entryset.setValue(entryset.getValue()+Integer.parseInt(arr[i+2]));
}
}

}
}
}