Last active
April 14, 2017 14:01
OrderPresenter Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// **OrderPresenter class** which extends Order Class (the actual model class) | |
public class OrderPresenter extends Order { | |
String defaultPicture = "https://cdn.pixabay.com/photo/2015/03/04/22/35/head-659652_960_720.png"; | |
public OrderPresenter(Customer customer, String status, float price, String cusPicURL, String firstName, String lastName, Date time, List<ItemsNum> lineItems, List<Sub_Orders> subOrders, Address cusAdress) { | |
super(customer, status, price, cusPicURL, firstName, lastName, time, lineItems, subOrders, cusAdress); | |
} | |
public String getFullName() { | |
return customer.getFirstName() + " " + customer.getLastName(); | |
} | |
public String getFullAddress() { | |
return cusAdress.getAddress() + " " + | |
cusAdress.getCity() + " " + | |
cusAdress.getState() + " " + | |
cusAdress.getCountry(); | |
} | |
public String getItemsCount() { | |
return String.valueOf(getLineItems().size()); | |
} | |
public String getOrderTime() { | |
Calendar calendar = Calendar.getInstance(); | |
calendar.setTime(getTime()); | |
return calendar.get(Calendar.MINUTE) + "د"; | |
} | |
public String getCustomerPicture() { | |
return customer.getCusPicURL().isEmpty() ? defaultPicture : customer.getCusPicURL(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment