1 package de.dhbwloe.campusapp.mensaplan;
3 import java.text.DateFormat;
4 import java.text.ParseException;
5 import java.text.SimpleDateFormat;
7 import java.util.Locale;
8 import java.util.zip.CRC32;
11 * Created by pk910 on 22.01.2016.
13 public class MensaTagesplan {
14 private long iPlanDate;
16 private String sMenuName, sName, sNameHtml, sAdditional, sNotes;
17 private int[] aPriceArray = new int[4];
19 private boolean bIsNew = false;
21 public MensaTagesplan(long plandate, String menuname, long chksum, String name, String namehtml, String additional, String notes, int price1, int price2, int price3, int price4) {
27 sAdditional = (additional == null ? "" : additional);
29 aPriceArray[0] = price1; // Student
30 aPriceArray[1] = price2; // Employees
31 aPriceArray[2] = price3; // Guest
32 aPriceArray[3] = price4; // School
35 public long calculateChkSum() {
36 CRC32 crc = new CRC32();
37 crc.update(sMenuName.getBytes());
39 crc.update(sName.getBytes());
41 crc.update(sNameHtml.getBytes());
42 if(sAdditional!= null)
43 crc.update(sAdditional.getBytes());
45 crc.update(sNotes.getBytes());
46 crc.update(aPriceArray[0]);
47 crc.update(aPriceArray[1]);
48 crc.update(aPriceArray[2]);
49 crc.update(aPriceArray[3]);
51 long crcvalue = crc.getValue();
56 public long getPlanDate() {
60 public String getFormatedDate() {
61 DateFormat df = new SimpleDateFormat("dd.MM.yyyy", Locale.ENGLISH);
62 return df.format(new Date(iPlanDate * 1000));
65 public long getChkSum() {
69 public String getMenuName() {
73 public String getName() {
77 public String getNameHtml() {
81 public String getAdditional() {
85 public String getNotes() {
89 public int[] getPlainPrice() {
93 public double getStudentPrice() {
94 double price = (aPriceArray[0] / 100.0);
98 public double getEmployeePrice() {
99 double price = (aPriceArray[1] / 100.0);
103 public double getGuestPrice() {
104 double price = (aPriceArray[2] / 100.0);
108 public double getSchoolPrice() {
109 double price = (aPriceArray[3] / 100.0);
113 public void setIsNew() {
117 public boolean getIsNew(boolean reset) {
118 boolean isnew = bIsNew;