1 package de.dhbwloe.campusapp.mensaplan;
3 import java.text.DateFormat;
4 import java.text.DecimalFormat;
5 import java.text.ParseException;
6 import java.text.SimpleDateFormat;
8 import java.util.Locale;
9 import java.util.zip.CRC32;
11 import de.dhbwloe.campusapp.CampusAppContext;
12 import de.dhbwloe.campusapp.R;
15 * Created by pk910 on 22.01.2016.
17 public class MensaTagesplan {
18 private long iPlanDate;
20 private String sMenuName, sName, sNameHtml, sAdditional, sNotes;
21 private int[] aPriceArray = new int[4];
23 private boolean bIsNew = false;
25 public MensaTagesplan(long plandate, String menuname, long chksum, String name, String namehtml, String additional, String notes, int price1, int price2, int price3, int price4) {
31 sAdditional = (additional == null ? "" : additional);
33 aPriceArray[0] = price1; // Student
34 aPriceArray[1] = price2; // Employees
35 aPriceArray[2] = price3; // Guest
36 aPriceArray[3] = price4; // School
39 public long calculateChkSum() {
40 CRC32 crc = new CRC32();
41 crc.update(sMenuName.getBytes());
43 crc.update(sName.getBytes());
45 crc.update(sNameHtml.getBytes());
46 if(sAdditional!= null)
47 crc.update(sAdditional.getBytes());
49 crc.update(sNotes.getBytes());
50 crc.update(aPriceArray[0]);
51 crc.update(aPriceArray[1]);
52 crc.update(aPriceArray[2]);
53 crc.update(aPriceArray[3]);
55 long crcvalue = crc.getValue();
60 public long getPlanDate() {
64 public String getFormatedDate() {
65 DateFormat df = new SimpleDateFormat("dd.MM.yyyy", Locale.ENGLISH);
66 return df.format(new Date(iPlanDate * 1000));
69 public long getChkSum() {
73 public String getMenuName() {
77 public String getName() {
81 public String getNameHtml() {
85 public String getAdditional() {
89 public String getNotes() {
93 public int[] getPlainPrice() {
97 public double getStudentPrice() {
98 double price = (aPriceArray[0] / 100.0);
102 public double getEmployeePrice() {
103 double price = (aPriceArray[1] / 100.0);
107 public double getGuestPrice() {
108 double price = (aPriceArray[2] / 100.0);
112 public double getSchoolPrice() {
113 double price = (aPriceArray[3] / 100.0);
117 public String getFormatedRolePrice() {
118 String mensaRoleName = CampusAppContext.getInstance().getDatabaseManager().getRuntimeCache("MensaRole");
119 if (mensaRoleName == null || mensaRoleName.isEmpty())
121 int mensaRole = Integer.parseInt(mensaRoleName);
122 double price = (aPriceArray[mensaRole] / 100.0);
124 DecimalFormat df = new DecimalFormat(CampusAppContext.getInstance().getResString(R.string.mensaformat_price));
125 String formatedPrice = df.format(price);
126 return formatedPrice;
129 public void setIsNew() {
133 public boolean getIsNew(boolean reset) {
134 boolean isnew = bIsNew;