From 97b1e0d4820606bef726f60e459b66afb1e8eab1 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期五, 21 十一月 2025 11:50:51 +0800
Subject: [PATCH] 优化与日志
---
ycl-server/src/main/java/com/ycl/api/DH/common/CaseMenu.java | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/ycl-server/src/main/java/com/ycl/api/DH/common/CaseMenu.java b/ycl-server/src/main/java/com/ycl/api/DH/common/CaseMenu.java
index 7a573ab..901b3ad 100644
--- a/ycl-server/src/main/java/com/ycl/api/DH/common/CaseMenu.java
+++ b/ycl-server/src/main/java/com/ycl/api/DH/common/CaseMenu.java
@@ -1,4 +1,4 @@
-package com.netsdk.common;
+package com.ycl.api.DH.common;
import java.lang.reflect.Method;
import java.util.NoSuchElementException;
@@ -6,12 +6,12 @@
import java.util.Vector;
public class CaseMenu {
-
+
public static class Item {
private Object object;
private String itemName;
private String methodName;
-
+
public Item(Object object, String itemName, String methodName) {
super();
this.object = object;
@@ -31,33 +31,33 @@
return methodName;
}
}
-
+
private Vector<Item> items;
public CaseMenu() {
super();
items = new Vector<Item>();
}
-
+
public void addItem(Item item) {
items.add(item);
}
-
+
private void showItem() {
final String format = "%2d\t%-20s\n";
- int index = 0;
+ int index = 0;
System.out.printf(format, index++, "exit App");
for (Item item : items) {
System.out.printf(format, index++, item.getItemName());
}
System.out.println("Please input a item index to invoke the method:");
}
-
+
public void run() {
Scanner scanner = new Scanner(System.in);
- while(true) {
- showItem();
- try {
+ while(true) {
+ showItem();
+ try {
int input = Integer.parseInt(scanner.nextLine());
if (input <= 0 ) {
@@ -66,12 +66,12 @@
// System.exit(0);
break;
}
-
+
if (input < 0 || input > items.size()) {
System.err.println("Input Error Item Index.");
continue;
}
-
+
Item item = items.get(input - 1);
Class<?> itemClass = item.getObject().getClass();
Method method = itemClass.getMethod(item.getMethodName());
@@ -85,9 +85,9 @@
continue;
} catch (Exception e) {
e.printStackTrace();
- }
+ }
}
-
+
scanner.close();
}
}
--
Gitblit v1.8.0