⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reservation.java

📁 这是一个小旅馆运行程序,很实用也很全面.希望对大家有所启发.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			}			f1 = (String[]) al3.get(6);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			f1 = (String[]) al3.get(7);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			// Vier-Bett Zimmer 黚er alle Stockwerke			f1 = (String[]) al4.get(0);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			f1 = (String[]) al4.get(1);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			f1 = (String[]) al4.get(2);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			f1 = (String[]) al4.get(3);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			f1 = (String[]) al4.get(4);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			f1 = (String[]) al4.get(5);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			f1 = (String[]) al4.get(6);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			f1 = (String[]) al4.get(7);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			// Apartments 黚er alle Stockwerke			f1 = (String[]) al5.get(0);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			f1 = (String[]) al5.get(1);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			f1 = (String[]) al5.get(2);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			f1 = (String[]) al5.get(3);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			f1 = (String[]) al5.get(4);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			f1 = (String[]) al5.get(5);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			f1 = (String[]) al5.get(6);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			f1 = (String[]) al5.get(7);						for (int i=0; i<f1.length; ++i) {				availableRooms[j] = f1[i];				++j;				reservations.add(new String[100000]);			}			reservations.add(availableRooms);		}		catch (ClassNotFoundException cnf) {			System.out.println(cnf);		}		catch (IOException io) {			System.out.println(io);		}				try {			FileOutputStream fos = new FileOutputStream("./db/restable.jh");			ObjectOutputStream oos = new ObjectOutputStream(fos);						oos.writeObject(reservations);			oos.flush();			oos.close();		}		catch (IOException io) {			System.out.println(io);		}	}			public int createCal(String date) {		int day, month, year;				day = Integer.parseInt(date.substring(0, 2));		month = Integer.parseInt(date.substring(3, 5));				try {			year = Integer.parseInt(date.substring(6, 10));		}		catch (StringIndexOutOfBoundsException sioob) {			year = Integer.parseInt(("20") + date.substring(6, 8));		}		int days = 0;		for (int i=2004; i<year; ++i) {			if (isLeapYear(i)) {				days = days + 366;			}			else {				days = days + 365;			}		}				for (int i=1; i<month; ++i) {			if (i==1) {				days = days + 31;			}			else if (i==2) {				if (isLeapYear(year)) {					days = days + 29;				}				else {					days = days + 28;				}			}			else if (i==3) {				days = days + 31;			}			else if (i==4) {				days = days + 30;			}			else if (i==5) {				days = days + 31;			}			else if (i==6) {				days = days + 30;			}			else if (i==7) {				days = days + 31;			}			else if (i==8) {				days = days +  31;			}			else if (i==9) {				days = days + 30;			}			else if (i==10) {				days = days + 31;			}			else if (i==11) {				days = days + 30;			}			else if (i==12) {				days = days + 31;			}		}				days = days + day;				return days;	}		public boolean isLeapYear(int year) {		boolean isLY = false;				if ((year % 4)!=0) {			isLY = false; 		}		else if (((year % 4) == 0) && ((year % 100) == 0) && (year % 1000) == 0) {			isLY = true;		}		else if ((year % 4) == 0 && ((year % 100) == 0)) {			isLY = false;		}		else if ((year % 4) == 0) {			isLY = true;		}				return isLY;	}		public boolean checkAvailability(int arrival, int departure, String room) {		boolean available = true;		ArrayList reservations = new ArrayList();		String[] availableRooms = new String[168];		String[] tmp;		int index=0;				try {			FileInputStream fis = new FileInputStream("./db/restable.jh");			ObjectInputStream ois = new ObjectInputStream(fis);						reservations = (ArrayList) ois.readObject();			ois.close();						availableRooms = (String[]) reservations.get(reservations.size()-1);						loop1:			for (int i=0; i<availableRooms.length; ++i) {				if (availableRooms[i].equals(room)) {					index = i;					break loop1;				}			}									tmp = (String[]) reservations.get(index);			loop1:			for (int i=arrival; i<departure; ++i) {				if (tmp[i]!=null) {					available = false;					break loop1;				}			}		}		catch (ClassNotFoundException cnf) {			System.out.println(cnf + " Reservation.makeReservation()");		}		catch (IOException io) {			System.out.println(io + " Reservation.makeReservation()");		}				return available;	}		public int[] calcDate() {		int[] days = new int[2];		Calendar cal = Calendar.getInstance();		int year = cal.get(Calendar.YEAR);		int month = cal.get(Calendar.MONTH);		int daysInMonth;		String f;		String l;				//jComboBox.setSelectedItem(Integer.toString(year));				if ((month==0) || (month==2) || (month==4) || (month==6) || (month==7) || (month==9) || (month==11)) {			daysInMonth = 31;		}		else if (month==1) {			if (isLeapYear(year)) {				daysInMonth = 29;			}			else {				daysInMonth = 28;			}		}		else {			daysInMonth = 30;		}				if (month<9) {			f = "01.0" + (month+1) + "." + year;			l = daysInMonth + ".0" + (month+1) + "." + year;		}		else {			f = "01." + (month+1) + "." + year;			l = daysInMonth + "." + (month+1) + "." + year;		}				days[0] = createCal(f);		days[1] = createCal(l);		return days;	}		public int[] calcDate(int month, int year) {		int[] days = new int[2];		Calendar cal = Calendar.getInstance();		int daysInMonth;		String f;		String l;				if ((month==0) || (month==2) || (month==4) || (month==6) || (month==7) || (month==9) || (month==11)) {			daysInMonth = 31;		}		else if (month==1) {			if (isLeapYear(year)) {				daysInMonth = 29;			}			else {				daysInMonth = 28;			}		}		else {			daysInMonth = 30;		}				if (month<9) {			f = "01.0" + (month+1) + "." + year;			l = daysInMonth + ".0" + (month+1) + "." + year;		}		else {			f = "01." + (month+1) + "." + year;			l = daysInMonth + "." + (month+1) + "." + year;		}				days[0] = createCal(f);		days[1] = createCal(l);		return days;	}			/*public static void main(String[] args) {		MainWindow mw = new MainWindow();		mw.setVisible(false);		ReservationManagement rm = new ReservationManagement(mw);		rm.setVisible(false);		Reservation res = new Reservation(rm);				//res.makeReservation(9, 11, "Chris Olbertz", "10");		//res.checkAvailability(10, 11, "10");		res.createResTable();		System.exit(0);	}*/}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -