src/control_layer/Controller.java
public boolean validateOrdinaryUser(String email) {
		try {
			this.user = DBManager.getInstance().getOrdinaryUser(email);
			DBManager.getInstance().populateUserReservation(user, theaterList, movieList); // Populate reservation.

			Calendar r = ((OrdinaryUser) user).getCalendar();
			int[] res = { (r.get(Calendar.YEAR) - 1), (r.get(Calendar.MONTH) + 12), r.get(Calendar.DAY_OF_MONTH),
					r.get(Calendar.HOUR_OF_DAY), r.get(Calendar.MINUTE) };
			Calendar calendar = Calendar.getInstance();

			int year = res[0] - calendar.get(Calendar.YEAR);
			int month = res[1] - (calendar.get(Calendar.MONTH) + 1);
			int day = res[2] - calendar.get(Calendar.DAY_OF_MONTH);
			int hour = res[3] - calendar.get(Calendar.HOUR_OF_DAY);

			int time = year * 8760 + month * 730 + day * 24 + hour;
			System.out.println(year + "+" + month + "+" + day + "+" + hour);

			if (time < 8759) {
				((OrdinaryUser) user).setCredit(0);
			} else {

			}
			return true;
		} catch (SQLException e) {
			// System.out.println("User with given email already existed!");
			// e.printStackTrace();
			return false;
		}
	}
/*
	 * Validate ordinary user. If user doesn't exist, create ordinary user with the
	 * given email.
	 */
Validate ordinary user. If user doesn't exist, create ordinary user with the
given email.
Validate ordinary user . If user doesn ' t exist create ordinary user with the given email .
public boolean validateOrdinaryUser(String email) {
		try {
			this.user = DBManager.getInstance().getOrdinaryUser(email);
			DBManager.getInstance().populateUserReservation(user, theaterList, movieList); 
			Calendar r = ((OrdinaryUser) user).getCalendar();
			int[] res = { (r.get(Calendar.YEAR) - 1), (r.get(Calendar.MONTH) + 12), r.get(Calendar.DAY_OF_MONTH),
					r.get(Calendar.HOUR_OF_DAY), r.get(Calendar.MINUTE) };
			Calendar calendar = Calendar.getInstance();
			int year = res[0] - calendar.get(Calendar.YEAR);
			int month = res[1] - (calendar.get(Calendar.MONTH) + 1);
			int day = res[2] - calendar.get(Calendar.DAY_OF_MONTH);
			int hour = res[3] - calendar.get(Calendar.HOUR_OF_DAY);
			int time = year * 8760 + month * 730 + day * 24 + hour;
			System.out.println(year + "+" + month + "+" + day + "+" + hour);
			if (time < 8759) {
				((OrdinaryUser) user).setCredit(0);
			} else {
			}
			return true;
		} catch (SQLException e) {
			return false;
		}
	}
public boolean validateOrdinaryUser ( String email ) { try { this . user = DBManager . getInstance ( ) . getOrdinaryUser ( email ) ; DBManager . getInstance ( ) . populateUserReservation ( user , theaterList , movieList ) ; Calendar r = ( ( OrdinaryUser ) user ) . getCalendar ( ) ; int [ ] res = { ( r . get ( Calendar . YEAR ) - 1 ) , ( r . get ( Calendar . MONTH ) + 12 ) , r . get ( Calendar . DAY_OF_MONTH ) , r . get ( Calendar . HOUR_OF_DAY ) , r . get ( Calendar . MINUTE ) } ; Calendar calendar = Calendar . getInstance ( ) ; int year = res [ 0 ] - calendar . get ( Calendar . YEAR ) ; int month = res [ 1 ] - ( calendar . get ( Calendar . MONTH ) + 1 ) ; int day = res [ 2 ] - calendar . get ( Calendar . DAY_OF_MONTH ) ; int hour = res [ 3 ] - calendar . get ( Calendar . HOUR_OF_DAY ) ; int time = year * 8760 + month * 730 + day * 24 + hour ; System . out . println ( year + "+" + month + "+" + day + "+" + hour ) ; if ( time < 8759 ) { ( ( OrdinaryUser ) user ) . setCredit ( 0 ) ; } else { } return true ; } catch ( SQLException e ) { return false ; } }
Validate ordinary user.
Validate ordinary user .
// Populate reservation. // System.out.println("User with given email already existed!"); // e.printStackTrace();