private static void deleteRoom(Scanner user) {//删除房间方法 System.out.println("当前您的车辆清单如下:"); System.out.println("1.高级大床房 拥有"+(BigBed.leixing[0])); System.out.println("2.豪华大床房 拥有"+(BigBed.leixing[1])); System.out.println("3.景观大床房 拥有"+(BigBed.leixing[2])); System.out.println("1.标准双床房 拥有"+(DoubleFang.leixing[0])); System.out.println("2.高级双床房 拥有"+(DoubleFang.leixing[1])); System.out.println("3.豪华双床房 拥有"+(DoubleFang.leixing[2])); System.out.println("1.景致小套房 拥有"+(TaoFang.leixing[0])); System.out.println("2.婴儿小套房 拥有"+(TaoFang.leixing[1])); System.out.println("3.亲子大套房 拥有"+(TaoFang.leixing[2])); //打印当前房间情况 System.out.println("请您输入要增加的房间的大类型,1-大床房,2-双床房,3-套房:"); int userIn=user.nextInt(); if(userIn==1) { System.out.println("1.高级大床房 拥有"+(BigBed.leixing[0])); System.out.println("2.豪华大床房 拥有"+(BigBed.leixing[1])); System.out.println("3.景观大床房 拥有"+(BigBed.leixing[2])); } else if(userIn==2) { System.out.println("1.标准双床房 拥有"+(DoubleFang.leixing[0])); System.out.println("2.高级双床房 拥有"+(DoubleFang.leixing[1])); System.out.println("3.豪华双床房 拥有"+(DoubleFang.leixing[2])); } else if(userIn==3) { System.out.println("1.景致小套房 拥有"+(TaoFang.leixing[0])); System.out.println("2.婴儿小套房 拥有"+(TaoFang.leixing[1])); System.out.println("3.亲子大套房 拥有"+(TaoFang.leixing[2])); } System.out.println("输入具体添加法房间的类型:"); int userOut=user.nextInt(); if(userIn==1) { BigBeddd.remove(BigBeddd.size()-1); BigBed.leixing[userOut-1]--; } else if(userIn==2) { DoubleFangdd.remove(DoubleFangdd.size()-1); DoubleFang.leixing[userOut-1]--; } else if(userIn==3) { TaoFangdd.remove(TaoFangdd.size()-1); TaoFang.leixing[userOut-1]--; } System.out.println("房间删除成功!"); }这段代码为什么不能输出
时间: 2024-03-22 09:37:01 浏览: 95
这段代码无法输出是因为它没有被调用,即没有在其他方法中被调用。您需要在其他方法中调用该方法才能执行其中的代码并输出结果。例如,您可以在主方法中调用该方法,如下所示:
```
public static void main(String[] args) {
Scanner user = new Scanner(System.in);
deleteRoom(user); // 调用删除房间方法
}
```
这样就可以执行 `deleteRoom()` 方法中的代码并输出结果。当然,您也可以在其他方法中调用该方法,具体取决于您的程序逻辑。
相关问题
帮我用Java编写一个简单的旅店管理系统
好的,以下是一个简单的旅店管理系统的Java代码示例。
这个系统包含两个功能:客房管理和顾客管理。
客房管理包括添加客房、删除客房、查询客房信息等;顾客管理包括添加顾客、删除顾客、查询顾客信息等。
```java
import java.util.ArrayList;
import java.util.Scanner;
public class HotelManagementSystem {
private ArrayList<Room> rooms = new ArrayList<>();
private ArrayList<Customer> customers = new ArrayList<>();
public static void main(String[] args) {
HotelManagementSystem system = new HotelManagementSystem();
system.run();
}
private void run() {
Scanner scanner = new Scanner(System.in);
while (true) {
System.out.println("请选择功能:");
System.out.println("1. 客房管理");
System.out.println("2. 顾客管理");
System.out.println("3. 退出系统");
int choice = scanner.nextInt();
switch (choice) {
case 1:
roomManagement();
break;
case 2:
customerManagement();
break;
case 3:
System.out.println("谢谢使用!");
return;
default:
System.out.println("无效的选择,请重新选择。");
}
}
}
private void roomManagement() {
Scanner scanner = new Scanner(System.in);
while (true) {
System.out.println("请选择客房管理功能:");
System.out.println("1. 添加客房");
System.out.println("2. 删除客房");
System.out.println("3. 查询客房信息");
System.out.println("4. 返回上一级");
int choice = scanner.nextInt();
switch (choice) {
case 1:
addRoom();
break;
case 2:
deleteRoom();
break;
case 3:
queryRoom();
break;
case 4:
return;
default:
System.out.println("无效的选择,请重新选择。");
}
}
}
private void addRoom() {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入客房号码:");
int number = scanner.nextInt();
System.out.println("请输入客房类型(单人间、双人间、豪华套房):");
String type = scanner.next();
System.out.println("请输入客房价格:");
double price = scanner.nextDouble();
Room room = new Room(number, type, price);
rooms.add(room);
System.out.println("客房添加成功。");
}
private void deleteRoom() {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入客房号码:");
int number = scanner.nextInt();
for (Room room : rooms) {
if (room.getNumber() == number) {
rooms.remove(room);
System.out.println("客房删除成功。");
return;
}
}
System.out.println("客房不存在。");
}
private void queryRoom() {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入客房号码:");
int number = scanner.nextInt();
for (Room room : rooms) {
if (room.getNumber() == number) {
System.out.println("客房信息如下:");
System.out.println(room);
return;
}
}
System.out.println("客房不存在。");
}
private void customerManagement() {
Scanner scanner = new Scanner(System.in);
while (true) {
System.out.println("请选择顾客管理功能:");
System.out.println("1. 添加顾客");
System.out.println("2. 删除顾客");
System.out.println("3. 查询顾客信息");
System.out.println("4. 返回上一级");
int choice = scanner.nextInt();
switch (choice) {
case 1:
addCustomer();
break;
case 2:
deleteCustomer();
break;
case 3:
queryCustomer();
break;
case 4:
return;
default:
System.out.println("无效的选择,请重新选择。");
}
}
}
private void addCustomer() {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入顾客姓名:");
String name = scanner.next();
System.out.println("请输入顾客性别(男、女):");
String gender = scanner.next();
System.out.println("请输入顾客年龄:");
int age = scanner.nextInt();
Customer customer = new Customer(name, gender, age);
customers.add(customer);
System.out.println("顾客添加成功。");
}
private void deleteCustomer() {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入顾客姓名:");
String name = scanner.next();
for (Customer customer : customers) {
if (customer.getName().equals(name)) {
customers.remove(customer);
System.out.println("顾客删除成功。");
return;
}
}
System.out.println("顾客不存在。");
}
private void queryCustomer() {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入顾客姓名:");
String name = scanner.next();
for (Customer customer : customers) {
if (customer.getName().equals(name)) {
System.out.println("顾客信息如下:");
System.out.println(customer);
return;
}
}
System.out.println("顾客不存在。");
}
private class Room {
private int number;
private String type;
private double price;
public Room(int number, String type, double price) {
this.number = number;
this.type = type;
this.price = price;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
@Override
public String toString() {
return "客房号码:" + number + ",客房类型:" + type + ",客房价格:" + price;
}
}
private class Customer {
private String name;
private String gender;
private int age;
public Customer(String name, String gender, int age) {
this.name = name;
this.gender = gender;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public String toString() {
return "顾客姓名:" + name + ",顾客性别:" + gender + ",顾客年龄:" + age;
}
}
}
```
以上是一个非常基础的旅店管理系统,只包含了客房管理和顾客管理两个功能,并没有实现数据持久化等高级功能。如果您需要更加完整和复杂的旅店管理系统,需要进行更加深入的开发和设计。
酒店管理系统房间管理网页设计加上增删改查js详细代码
酒店管理系统中,房间管理的网页设计通常涉及到前端的HTML、CSS以及JavaScript交互部分。这里是一个简单的示例,展示如何使用JavaScript实现基本的增删改查操作:
1. HTML结构 (创建页面布局):
```html
<!DOCTYPE html>
<html lang="zh">
<head>
<title>酒店房间管理</title>
</head>
<body>
<h2>房间列表</h2>
<table id="roomTable">
<!-- 表格行将动态添加 -->
</table>
<button onclick="addRoom()">新增房间</button>
<form id="editForm">
<input type="hidden" id="roomId">
<label for="roomName">房间名称:</label>
<input type="text" id="roomName" required>
... 其他房间信息输入字段 ...
<button onclick="updateRoom()">保存修改</button>
</form>
<script src="roomManagement.js"></script>
</body>
</html>
```
2. JavaScript (房间管理函数) - roomManagement.js:
```javascript
// 假设我们有一个数组模拟房间数据
var rooms = [];
// 添加房间函数
function addRoom() {
var newRow = '<tr><td>' + prompt("请输入房间编号") + '</td><td>' + document.getElementById('roomName').value + '</td>...</tr>';
document.getElementById('roomTable').innerHTML += newRow;
}
// 更新房间函数 (假设已获取到房间ID)
function updateRoom() {
var roomId = document.getElementById('roomId').value;
var index = rooms.findIndex(room => room.id === parseInt(roomId));
if (index !== -1) {
rooms[index].name = document.getElementById('roomName').value; // 修改房间名等属性
displayRooms(); // 刷新显示
} else {
alert("房间不存在");
}
}
// 删除房间函数 (同样需要房间ID)
function deleteRoom() {
var roomId = prompt("请输入要删除的房间编号");
rooms = rooms.filter(room => room.id !== parseInt(roomId));
displayRooms();
}
// 显示房间列表
function displayRooms() {
var tableBody = document.getElementById('roomTable').getElementsByTagName('tbody')[0];
tableBody.innerHTML = '';
rooms.forEach(room => {
var row = `<tr><td>${room.id}</td><td>${room.name}</td>...</tr>`;
tableBody.appendChild(document.createElement('tr').innerHTML = row);
});
}
```
这只是一个基础的例子,实际项目中可能还需要后端的支持,例如通过AJAX请求向服务器发送增删改查操作并处理响应。
阅读全文