这是一个使用C#实现的酒店管理系统。
首先,定义了一个Room类,表示酒店的房间,包括房间号、是否入住和客人姓名等属性。
public class Room
{
public int RoomNumber { get; set; } // 房间号
public bool IsOccupied { get; set; } // 是否入住
public string GuestName { get; set; } // 客人姓名
}
然后,定义了一个HotelManagementSystem类,表示酒店管理系统,包括房间列表和各种操作方法。
public class HotelManagementSystem
{
private List<Room> rooms; // 房间列表
public HotelManagementSystem()
{
rooms = new List<Room>();
for (int i = 1; i <= 100; i++)
{
rooms.Add(new Room { RoomNumber = i, IsOccupied = false, GuestName = "" });
}
}
// C端展示房间信息
public void DisplayRooms()
{
Console.WriteLine("酒店房间信息:");
foreach (var room in rooms)
{
Console.WriteLine($"房间号:{room.RoomNumber},状态:{(room.IsOccupied ? "已入住" : "空闲")}");
}
}
// 前台操作
public void FrontDeskOperation()
{
Console.WriteLine("欢迎来到前台操作界面!");
Console.WriteLine("1. 登记入住");
Console.WriteLine("2. 入住管理");
Console.WriteLine("3. 职位管理");
Console.WriteLine("4. 公告系统");
Console.WriteLine("5. 返回上一级");
int choice = Convert.ToInt32(Console.ReadLine());
switch (choice)
{
case 1:
RegisterCheckIn();
break;
case 2:
ManageCheckIn();
break;
case 3:
ManagePositions();
break;
case 4:
AnnouncementSystem();
break;
case 5:
break;
default:
Console.WriteLine("无效的选项!");
break;
}
}
// 登记入住
private void RegisterCheckIn()
{
Console.WriteLine("请输入客人姓名:");
string guestName = Console.ReadLine();
// 查找空闲房间
Room availableRoom = rooms.Find(room => room.IsOccupied == false);
if (availableRoom != null)
{
availableRoom.IsOccupied = true;
availableRoom.GuestName = guestName;
Console.WriteLine($"客人 {guestName} 已成功入住房间 {availableRoom.RoomNumber}!");
}
else
{
Console.WriteLine("抱歉,当前没有空闲房间!");
}
}
// 入住管理
private void ManageCheckIn()
{
Console.WriteLine("请输入房间号:");
int roomNumber = Convert.ToInt32(Console.ReadLine());
// 查找指定房间
Room room = rooms.Find(r => r.RoomNumber == roomNumber);
if (room != null)
{
if (room.IsOccupied)
{
Console.WriteLine($"房间 {roomNumber} 当前入住客人:{room.GuestName}");
}
else
{
Console.WriteLine($"房间 {roomNumber} 当前为空闲!");
}
}
else
{
Console.WriteLine($"找不到房间号为 {roomNumber} 的房间!");
}
}
// 职位管理
private void ManagePositions()
{
Console.WriteLine("职位管理功能尚未实现!");
}
// 公告系统
private void AnnouncementSystem()
{
Console.WriteLine("公告系统功能尚未实现!");
}
}
在主程序中,创建了一个HotelManagementSystem对象,并通过一个循环菜单让用户选择操作。用户可以选择展示房间信息、进行前台操作或退出系统。
public class Program
{
public static void Main(string[] args)
{
HotelManagementSystem hotelManagementSystem = new HotelManagementSystem();
while (true)
{
Console.WriteLine("欢迎使用酒店管理系统!");
Console.WriteLine("1. C端展示房间信息");
Console.WriteLine("2. 前台操作");
Console.WriteLine("3. 退出");
int choice = Convert.ToInt32(Console.ReadLine());
switch (choice)
{
case 1:
hotelManagementSystem.DisplayRooms();
break;
case 2:
hotelManagementSystem.FrontDeskOperation();
break;
case 3:
Environment.Exit(0);
break;
default:
Console.WriteLine("无效的选项!");
break;
}
}
}
}
这个酒店管理系统实现了简单的功能,可以展示房间信息,进行前台操作,包括登记入住、入住管理、职位管理和公告系统等。具体的实现细节可以根据实际需求进行修改和扩展。