一个酒店信息管理系统可以分为以下几个模块: 城市管理模块:用于维护系统中的城市信息,包括添加、删除、修改城市信息等功能。 酒店管理模块:用于维护系统中的酒店信息,包括添加、删除、修改酒店信息等功能。每个酒店可以上传若干照片,并维护不同价格的房间信息。 旅客注册模块:用于旅客注册,注册后可以查询酒店信息、预定房间、查看积分等功能。 酒店查询模块:用于查询指定日期、指定城市、指定价格、指定星级的酒店信息。 房间预定模块:用于旅客预定房间,声明最迟到达酒店日期。 入住管理模块:用于酒店前台办理入住,增加旅客积分等功能。 预定取消模块:用于旅客取消房间预定,系统会根据取消时间是否超出最迟到达酒店日期来判断是否扣除积分。 以上是一个简单的酒店信息管理系统的模块划分,具体实现流程可以根据您的需求进行调整和完善。java代码实现
时间: 2024-03-11 17:48:28 浏览: 12
以下是一个简单的Java代码实现,实现了酒店信息管理系统的基本功能:
City.java
```java
public class City {
private String name;
private List<Hotel> hotels;
public City(String name) {
this.name = name;
hotels = new ArrayList<>();
}
public String getName() {
return name;
}
public List<Hotel> getHotels() {
return hotels;
}
public void addHotel(Hotel hotel) {
hotels.add(hotel);
}
public void removeHotel(Hotel hotel) {
hotels.remove(hotel);
}
}
```
Hotel.java
```java
public class Hotel {
private String name;
private String address;
private int star;
private List<Room> rooms;
public Hotel(String name, String address, int star) {
this.name = name;
this.address = address;
this.star = star;
rooms = new ArrayList<>();
}
public String getName() {
return name;
}
public String getAddress() {
return address;
}
public int getStar() {
return star;
}
public List<Room> getRooms() {
return rooms;
}
public void addRoom(Room room) {
rooms.add(room);
}
public void removeRoom(Room room) {
rooms.remove(room);
}
}
```
Room.java
```java
public class Room {
private int number;
private int price;
public Room(int number, int price) {
this.number = number;
this.price = price;
}
public int getNumber() {
return number;
}
public int getPrice() {
return price;
}
}
```
Customer.java
```java
public class Customer {
private String name;
private int points;
private List<Reservation> reservations;
public Customer(String name) {
this.name = name;
points = 0;
reservations = new ArrayList<>();
}
public String getName() {
return name;
}
public int getPoints() {
return points;
}
public void addPoints(int points) {
this.points += points;
}
public List<Reservation> getReservations() {
return reservations;
}
public void addReservation(Reservation reservation) {
reservations.add(reservation);
}
public void removeReservation(Reservation reservation) {
reservations.remove(reservation);
}
}
```
Reservation.java
```java
public class Reservation {
private Customer customer;
private Hotel hotel;
private Room room;
private Date checkInDate;
private Date checkOutDate;
public Reservation(Customer customer, Hotel hotel, Room room, Date checkInDate, Date checkOutDate) {
this.customer = customer;
this.hotel = hotel;
this.room = room;
this.checkInDate = checkInDate;
this.checkOutDate = checkOutDate;
}
public Customer getCustomer() {
return customer;
}
public Hotel getHotel() {
return hotel;
}
public Room getRoom() {
return room;
}
public Date getCheckInDate() {
return checkInDate;
}
public Date getCheckOutDate() {
return checkOutDate;
}
}
```
HotelReservationSystem.java
```java
import java.util.*;
public class HotelReservationSystem {
private List<City> cities;
private List<Customer> customers;
public HotelReservationSystem() {
cities = new ArrayList<>();
customers = new ArrayList<>();
}
public void addCity(City city) {
cities.add(city);
}
public void removeCity(City city) {
cities.remove(city);
}
public List<City> getCities() {
return cities;
}
public List<Customer> getCustomers() {
return customers;
}
public void registerCustomer(Customer customer) {
customers.add(customer);
}
public List<Hotel> searchHotels(Date checkInDate, Date checkOutDate, String cityName, int maxPrice, int minStar) {
List<Hotel> result = new ArrayList<>();
for (City city : cities) {
if (city.getName().equals(cityName)) {
for (Hotel hotel : city.getHotels()) {
if (hotel.getStar() >= minStar) {
for (Room room : hotel.getRooms()) {
if (room.getPrice() <= maxPrice) {
boolean available = true;
for (Reservation reservation : customers.get(0).getReservations()) {
if (reservation.getHotel() == hotel && checkInDate.before(reservation.getCheckOutDate()) && checkOutDate.after(reservation.getCheckInDate())) {
available = false;
break;
}
}
if (available) {
result.add(hotel);
}
}
}
}
}
break;
}
}
return result;
}
public void reserveRoom(Customer customer, Hotel hotel, Room room, Date checkInDate, Date checkOutDate) throws Exception {
if (checkInDate.after(checkOutDate)) {
throw new Exception("Check-in date cannot be after check-out date");
}
Reservation reservation = new Reservation(customer, hotel, room, checkInDate, checkOutDate);
customer.addReservation(reservation);
customer.addPoints(room.getPrice());
}
public void cancelReservation(Customer customer, Reservation reservation) throws Exception {
if (reservation.getCheckInDate().before(new Date())) {
throw new Exception("Cannot cancel reservation after check-in date");
}
if (reservation.getCheckInDate().before(new Date(reservation.getCheckInDate().getTime() - 24 * 60 * 60 * 1000))) {
customer.addPoints(-reservation.getRoom().getPrice());
}
customer.removeReservation(reservation);
}
}
```
以上是一个简单的Java代码实现,包括了城市管理、酒店管理、旅客注册、酒店查询、房间预定、入住管理、预定取消等模块的实现。但这只是一个基本的实现,具体实现流程还需要根据您的需求进行调整和完善。