diff --git a/bin/assignment1/PasswordChange.class b/bin/assignment1/PasswordChange.class index 6337800..3c2f238 100644 Binary files a/bin/assignment1/PasswordChange.class and b/bin/assignment1/PasswordChange.class differ diff --git a/bin/assignment1/ProductAdditionAndInquiry.class b/bin/assignment1/ProductAdditionAndInquiry.class index 21d8df9..7f42f51 100644 Binary files a/bin/assignment1/ProductAdditionAndInquiry.class and b/bin/assignment1/ProductAdditionAndInquiry.class differ diff --git a/bin/assignment1/UserLogin.class b/bin/assignment1/UserLogin.class index 453b228..093c71e 100644 Binary files a/bin/assignment1/UserLogin.class and b/bin/assignment1/UserLogin.class differ diff --git a/bin/excel/Test.class b/bin/excel/Test.class index 54ed4ae..15d4156 100644 Binary files a/bin/excel/Test.class and b/bin/excel/Test.class differ diff --git a/bin/finalexam/Database/Cashier.class b/bin/finalexam/Database/Cashier.class index 00d1751..e9d2e66 100644 Binary files a/bin/finalexam/Database/Cashier.class and b/bin/finalexam/Database/Cashier.class differ diff --git a/bin/finalexam/Database/CashierStatistics.class b/bin/finalexam/Database/CashierStatistics.class index c8e0d6c..1c08170 100644 Binary files a/bin/finalexam/Database/CashierStatistics.class and b/bin/finalexam/Database/CashierStatistics.class differ diff --git a/bin/finalexam/Database/DataInput.class b/bin/finalexam/Database/DataInput.class index 7b6c42d..4bfecaa 100644 Binary files a/bin/finalexam/Database/DataInput.class and b/bin/finalexam/Database/DataInput.class differ diff --git a/bin/finalexam/Database/PasswordChange.class b/bin/finalexam/Database/PasswordChange.class index 7bf3af2..4a7aa3a 100644 Binary files a/bin/finalexam/Database/PasswordChange.class and b/bin/finalexam/Database/PasswordChange.class differ diff --git a/bin/finalexam/Database/ProductAdditionAndInquiry.class b/bin/finalexam/Database/ProductAdditionAndInquiry.class index e4865b5..4b0fab2 100644 Binary files a/bin/finalexam/Database/ProductAdditionAndInquiry.class and b/bin/finalexam/Database/ProductAdditionAndInquiry.class differ diff --git a/bin/finalexam/Database/UserLogin.class b/bin/finalexam/Database/UserLogin.class index 06443b3..99e7a59 100644 Binary files a/bin/finalexam/Database/UserLogin.class and b/bin/finalexam/Database/UserLogin.class differ diff --git a/src/assignment1/PasswordChange.java b/src/assignment1/PasswordChange.java index d89f9a8..a2a3f8f 100644 --- a/src/assignment1/PasswordChange.java +++ b/src/assignment1/PasswordChange.java @@ -13,7 +13,7 @@ public class PasswordChange { static final String DBURL = "jdbc:mysql://localhost:3306/xiaoshou?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT"; public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); + Scanner sc = new Scanner(System.in); Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; @@ -21,7 +21,7 @@ public class PasswordChange { Class.forName("com.mysql.cj.jdbc.Driver"); conn = DriverManager.getConnection(DBURL); System.out.print("请输入用户名:"); - String username = scanner.nextLine(); + String username = sc.nextLine(); String checkUserSql = "SELECT xingming FROM t_yong WHERE yonghuming=?"; pstmt = conn.prepareStatement(checkUserSql); pstmt.setString(1, username); @@ -31,7 +31,7 @@ public class PasswordChange { return; } System.out.print("请输入当前用户的原密码:"); - String oldPassword = scanner.nextLine(); + String oldPassword = sc.nextLine(); String checkPasswordSql = "SELECT xingming FROM t_yong WHERE yonghuming=? AND mima=MD5(?)"; pstmt = conn.prepareStatement(checkPasswordSql); pstmt.setString(1, username); @@ -44,14 +44,14 @@ public class PasswordChange { String newPassword; while (true) { System.out.print("请设置新的密码:"); - newPassword = scanner.nextLine(); + newPassword = sc.nextLine(); if (!isPasswordComplex(newPassword)) System.out.println("您的密码不符合复杂性要求(密码长度不少于6个字符,至少有一个小写字母,至少有一个大写字母,至少一个数字),请重新输入:"); else break; } System.out.print("请输入确认密码:"); - String confirmPassword = scanner.nextLine(); + String confirmPassword = sc.nextLine(); if (!newPassword.equals(confirmPassword)) { System.out.println("两次输入的密码必须一致,请重新输入确认密码:"); return; diff --git a/src/assignment1/ProductAdditionAndInquiry.java b/src/assignment1/ProductAdditionAndInquiry.java index da4a24a..8d70246 100644 --- a/src/assignment1/ProductAdditionAndInquiry.java +++ b/src/assignment1/ProductAdditionAndInquiry.java @@ -12,7 +12,7 @@ public class ProductAdditionAndInquiry { private static final String DBURL = "jdbc:mysql://localhost:3306/xiaoshou?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT"; public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); + Scanner sc = new Scanner(System.in); int choice; try (Connection conn = DriverManager.getConnection(DBURL)) { do { @@ -21,14 +21,14 @@ public class ProductAdditionAndInquiry { System.out.println("2、查询商品"); System.out.println("3、退出"); System.out.print("请选择(1-3):"); - choice = scanner.nextInt(); - scanner.nextLine(); + choice = sc.nextInt(); + sc.nextLine(); switch (choice) { case 1: - addProduct(scanner, conn); + addProduct(sc, conn); break; case 2: - queryProduct(scanner, conn); + queryProduct(sc, conn); break; case 3: System.out.println("退出系统"); @@ -42,9 +42,9 @@ public class ProductAdditionAndInquiry { } } - private static void addProduct(Scanner scanner, Connection conn) throws SQLException { + private static void addProduct(Scanner sc, Connection conn) throws SQLException { System.out.print("请输入商品信息(格式:条形码,商品名称,单价,供应商):"); - String input = scanner.nextLine(); + String input = sc.nextLine(); String[] productInfo = input.split(","); String tiaoma = productInfo[0]; PreparedStatement checkStmt = conn.prepareStatement("SELECT COUNT(*) FROM t_shangping WHERE tiaoma = ?"); @@ -65,9 +65,9 @@ public class ProductAdditionAndInquiry { System.out.println("增加成功"); } - private static void queryProduct(Scanner scanner, Connection conn) throws SQLException { + private static void queryProduct(Scanner sc, Connection conn) throws SQLException { System.out.print("请输入查询的商品名称:"); - String nameQuery = scanner.nextLine(); + String nameQuery = sc.nextLine(); PreparedStatement queryStmt = conn.prepareStatement("SELECT * FROM t_shangping WHERE mingcheng LIKE ?"); queryStmt.setString(1, "%" + nameQuery + "%"); ResultSet rs = queryStmt.executeQuery(); diff --git a/src/assignment1/UserLogin.java b/src/assignment1/UserLogin.java index 8bf2178..a2ed440 100644 --- a/src/assignment1/UserLogin.java +++ b/src/assignment1/UserLogin.java @@ -13,7 +13,7 @@ public class UserLogin { static final String DBURL = "jdbc:mysql://localhost:3306/xiaoshou?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT"; public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); + Scanner sc = new Scanner(System.in); Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; @@ -25,9 +25,9 @@ public class UserLogin { while (attempts < 3 && !loginSuccess) { System.out.println("欢迎使用阳光超市收银系统,请登陆"); System.out.print("请输入用户名: "); - String username = scanner.nextLine(); + String username = sc.nextLine(); System.out.print("请输入密码: "); - String password = scanner.nextLine(); + String password = sc.nextLine(); String sql = "SELECT xingming FROM t_yong WHERE yonghuming=? AND mima=?"; pstmt = conn.prepareStatement(sql); pstmt.setString(1, username); diff --git a/src/excel/Test.java b/src/excel/Test.java index 813c3f0..68e68e0 100644 --- a/src/excel/Test.java +++ b/src/excel/Test.java @@ -16,7 +16,7 @@ import jxl.write.WritableWorkbook; public class Test { public static void main(String[] args) throws Exception { - Scanner scanner = new Scanner(System.in); + Scanner sc = new Scanner(System.in); WritableWorkbook book = Workbook.createWorkbook(new File("src/excel/求职简历.xls")); WritableFont font = new WritableFont(WritableFont.createFont("SimSun"), 11); WritableCellFormat borderFormat = new WritableCellFormat(font); @@ -52,29 +52,29 @@ public class Test { sheet.addCell(new Label(0, 18, "专长", borderFormat)); sheet.setRowView(0, 520); System.out.println("姓名:"); - sheet.addCell(new Label(1, 1, scanner.next(), borderFormat)); + sheet.addCell(new Label(1, 1, sc.next(), borderFormat)); System.out.println("性别:"); - sheet.addCell(new Label(3, 1, scanner.next(), borderFormat)); + sheet.addCell(new Label(3, 1, sc.next(), borderFormat)); System.out.println("籍贯:"); - sheet.addCell(new Label(5, 1, scanner.next(), borderFormat)); + sheet.addCell(new Label(5, 1, sc.next(), borderFormat)); System.out.println("出生日期:"); - sheet.addCell(new Label(1, 2, scanner.next(), borderFormat)); + sheet.addCell(new Label(1, 2, sc.next(), borderFormat)); System.out.println("民族:"); - sheet.addCell(new Label(3, 2, scanner.next(), borderFormat)); + sheet.addCell(new Label(3, 2, sc.next(), borderFormat)); System.out.println("邮箱:"); - sheet.addCell(new Label(5, 2, scanner.next(), borderFormat)); + sheet.addCell(new Label(5, 2, sc.next(), borderFormat)); System.out.println("家庭地址:"); - sheet.addCell(new Label(1, 3, scanner.next(), borderFormat)); + sheet.addCell(new Label(1, 3, sc.next(), borderFormat)); System.out.println("政治面貌:"); - sheet.addCell(new Label(1, 4, scanner.next(), borderFormat)); + sheet.addCell(new Label(1, 4, sc.next(), borderFormat)); System.out.println("电话:"); - sheet.addCell(new Label(3, 4, scanner.next(), borderFormat)); + sheet.addCell(new Label(3, 4, sc.next(), borderFormat)); System.out.println("专业:"); - sheet.addCell(new Label(5, 4, scanner.next(), borderFormat)); + sheet.addCell(new Label(5, 4, sc.next(), borderFormat)); System.out.println("个人简介:"); - sheet.addCell(new Label(0, 8, scanner.next(), borderFormat)); + sheet.addCell(new Label(0, 8, sc.next(), borderFormat)); System.out.println("特长:"); - sheet.addCell(new Label(0, 19, scanner.next(), borderFormat)); + sheet.addCell(new Label(0, 19, sc.next(), borderFormat)); for (int i = 0; i <= 5; i++) for (int j = 5; j <= 6; j++) sheet.addCell(new Label(i, j, " ", borderFormat)); diff --git a/src/finalexam/Database/Cashier.java b/src/finalexam/Database/Cashier.java index e004fd0..d2b75b4 100644 --- a/src/finalexam/Database/Cashier.java +++ b/src/finalexam/Database/Cashier.java @@ -17,23 +17,23 @@ public class Cashier { Connection conn = DriverManager.getConnection(DBURL); PreparedStatement pstmt = null; ResultSet rs = null; - Scanner scanner = new Scanner(System.in); + Scanner sc = new Scanner(System.in); boolean continueCashier = true; int sequence = 0; String lastDate = ""; while (continueCashier) { System.out.println("欢迎使用阳光超市收银系统"); System.out.print("请输入商品条形码(6位数字字符):"); - String barcode = scanner.nextLine(); + String barcode = sc.nextLine(); pstmt = conn.prepareStatement("SELECT * FROM t_shangping WHERE tiaoma = ?"); pstmt.setString(1, barcode); rs = pstmt.executeQuery(); if (rs.next()) { System.out.print("输入商品数量:"); - int quantity = scanner.nextInt(); - scanner.nextLine(); + int quantity = sc.nextInt(); + sc.nextLine(); System.out.print("请输入收银员:"); - String cashier = scanner.nextLine(); + String cashier = sc.nextLine(); String productName = rs.getString("mingcheng"); double price = rs.getDouble("danjia"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -59,7 +59,7 @@ public class Cashier { } else System.out.println("您输入的商品条形码不存在,请确认后重新输入"); System.out.print("是否继续收银(y/n):"); - String choice = scanner.nextLine(); + String choice = sc.nextLine(); if ("n".equalsIgnoreCase(choice)) continueCashier = false; } diff --git a/src/finalexam/Database/CashierStatistics.java b/src/finalexam/Database/CashierStatistics.java index 665a7e3..d974636 100644 --- a/src/finalexam/Database/CashierStatistics.java +++ b/src/finalexam/Database/CashierStatistics.java @@ -19,14 +19,14 @@ public class CashierStatistics { Connection conn = DriverManager.getConnection(DBURL); PreparedStatement pstmt = null; ResultSet rs = null; - Scanner scanner = new Scanner(System.in); + Scanner sc = new Scanner(System.in); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String inputDate; Date saleDate = null; boolean validDate = false; while (!validDate) { System.out.print("请输入销售日期(yyyy-mm-dd):"); - inputDate = scanner.nextLine(); + inputDate = sc.nextLine(); try { saleDate = sdf.parse(inputDate); validDate = true; @@ -61,7 +61,7 @@ public class CashierStatistics { String continueInput; do { System.out.print("是否继续查询(y/n):"); - continueInput = scanner.nextLine(); + continueInput = sc.nextLine(); if ("n".equalsIgnoreCase(continueInput)) { System.out.println("程序成功退出"); break; diff --git a/src/finalexam/Database/DataInput.java b/src/finalexam/Database/DataInput.java index 3fa1a8f..74a9934 100644 --- a/src/finalexam/Database/DataInput.java +++ b/src/finalexam/Database/DataInput.java @@ -22,13 +22,13 @@ public class DataInput { Connection conn = DriverManager.getConnection(DBURL); PreparedStatement pstmt = null; ResultSet rs = null; - Scanner scanner = new Scanner(System.in); + Scanner sc = new Scanner(System.in); System.out.println("====超市商品管理维护===="); System.out.println("1、从excel中导入数据"); System.out.println("2、从文本文件导入数据"); System.out.println("3、返回主菜单"); System.out.print("请选择(1-3):"); - int choice = scanner.nextInt(); + int choice = sc.nextInt(); int cnt = 0; switch (choice) { case 1: diff --git a/src/finalexam/Database/PasswordChange.java b/src/finalexam/Database/PasswordChange.java index 1db3526..71aa4ea 100644 --- a/src/finalexam/Database/PasswordChange.java +++ b/src/finalexam/Database/PasswordChange.java @@ -17,9 +17,9 @@ public class PasswordChange { Connection conn = DriverManager.getConnection(DBURL); PreparedStatement pstmt = null; ResultSet rs = null; - Scanner scanner = new Scanner(System.in); + Scanner sc = new Scanner(System.in); System.out.print("请输入用户名:"); - String username = scanner.nextLine(); + String username = sc.nextLine(); String checkUserSql = "SELECT xingming FROM t_yong WHERE yonghuming=?"; pstmt = conn.prepareStatement(checkUserSql); pstmt.setString(1, username); @@ -29,7 +29,7 @@ public class PasswordChange { return; } System.out.print("请输入当前用户的原密码:"); - String oldPassword = scanner.nextLine(); + String oldPassword = sc.nextLine(); String checkPasswordSql = "SELECT xingming FROM t_yong WHERE yonghuming=? AND mima=MD5(?)"; pstmt = conn.prepareStatement(checkPasswordSql); pstmt.setString(1, username); @@ -42,14 +42,14 @@ public class PasswordChange { String newPassword; while (true) { System.out.print("请设置新的密码:"); - newPassword = scanner.nextLine(); + newPassword = sc.nextLine(); if (!isPasswordComplex(newPassword)) System.out.println("您的密码不符合复杂性要求(密码长度不少于6个字符,至少有一个小写字母,至少有一个大写字母,至少一个数字),请重新输入:"); else break; } System.out.print("请输入确认密码:"); - String confirmPassword = scanner.nextLine(); + String confirmPassword = sc.nextLine(); if (!newPassword.equals(confirmPassword)) { System.out.println("两次输入的密码必须一致,请重新输入确认密码:"); return; diff --git a/src/finalexam/Database/ProductAdditionAndInquiry.java b/src/finalexam/Database/ProductAdditionAndInquiry.java index 71fd756..40b6a3b 100644 --- a/src/finalexam/Database/ProductAdditionAndInquiry.java +++ b/src/finalexam/Database/ProductAdditionAndInquiry.java @@ -15,7 +15,7 @@ public class ProductAdditionAndInquiry { public static void main(String[] args) throws Exception { Class.forName(DBDRIVER); Connection conn = DriverManager.getConnection(DBURL); - Scanner scanner = new Scanner(System.in); + Scanner sc = new Scanner(System.in); int choice; do { System.out.println("===超市商品管理维护===="); @@ -23,14 +23,14 @@ public class ProductAdditionAndInquiry { System.out.println("2、查询商品"); System.out.println("3、退出"); System.out.print("请选择(1-3):"); - choice = scanner.nextInt(); - scanner.nextLine(); + choice = sc.nextInt(); + sc.nextLine(); switch (choice) { case 1: - addProduct(scanner, conn); + addProduct(sc, conn); break; case 2: - queryProduct(scanner, conn); + queryProduct(sc, conn); break; case 3: System.out.println("退出系统"); @@ -42,9 +42,9 @@ public class ProductAdditionAndInquiry { conn.close(); } - private static void addProduct(Scanner scanner, Connection conn) throws SQLException { + private static void addProduct(Scanner sc, Connection conn) throws SQLException { System.out.print("请输入商品信息(格式:条形码,商品名称,单价,供应商):"); - String input = scanner.nextLine(); + String input = sc.nextLine(); String[] productInfo = input.split(","); String tiaoma = productInfo[0]; PreparedStatement checkStmt = conn.prepareStatement("SELECT COUNT(*) FROM t_shangping WHERE tiaoma = ?"); @@ -65,9 +65,9 @@ public class ProductAdditionAndInquiry { System.out.println("增加成功"); } - private static void queryProduct(Scanner scanner, Connection conn) throws SQLException { + private static void queryProduct(Scanner sc, Connection conn) throws SQLException { System.out.print("请输入查询的商品名称:"); - String nameQuery = scanner.nextLine(); + String nameQuery = sc.nextLine(); PreparedStatement queryStmt = conn.prepareStatement("SELECT * FROM t_shangping WHERE mingcheng LIKE ?"); queryStmt.setString(1, "%" + nameQuery + "%"); ResultSet rs = queryStmt.executeQuery(); diff --git a/src/finalexam/Database/UserLogin.java b/src/finalexam/Database/UserLogin.java index 329f447..7499c5b 100644 --- a/src/finalexam/Database/UserLogin.java +++ b/src/finalexam/Database/UserLogin.java @@ -17,15 +17,15 @@ public class UserLogin { Connection conn = DriverManager.getConnection(DBURL); PreparedStatement pstmt = null; ResultSet rs = null; - Scanner scanner = new Scanner(System.in); + Scanner sc = new Scanner(System.in); int attempts = 0; boolean loginSuccess = false; while (attempts < 3 && !loginSuccess) { System.out.println("欢迎使用阳光超市收银系统,请登陆"); System.out.print("请输入用户名: "); - String username = scanner.nextLine(); + String username = sc.nextLine(); System.out.print("请输入密码: "); - String password = scanner.nextLine(); + String password = sc.nextLine(); String sql = "SELECT xingming FROM t_yong WHERE yonghuming=? AND mima=?"; pstmt = conn.prepareStatement(sql); pstmt.setString(1, username);