Skip to content

Instantly share code, notes, and snippets.

@AlaaZarifa
Last active April 14, 2017 14:01
Show Gist options
  • Save AlaaZarifa/6632072c6ea05a6e52eaefddebc4c09c to your computer and use it in GitHub Desktop.
Save AlaaZarifa/6632072c6ea05a6e52eaefddebc4c09c to your computer and use it in GitHub Desktop.
OrderPresenter Class
// **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