海蓝色。 2021-06-30 19:20 采纳率: 89.7%
浏览 19
已采纳

Java图书项目完善一下view

package com.view;

import java.sql.SQLException; import java.util.Scanner;

import com.dao.UserDao; import com.model.User;

public class MainView {

public final static String up = "*********************************";

public static void MainMenu() throws SQLException{
    System.out.println("*********************************");
    System.out.println("*\t\t1.注册\t\t*");
    System.out.println("*\t\t2.登录\t\t*");
    System.out.print("请输入1/2,非法输入将退出\t\t");
    Scanner sc = new Scanner(System.in);
    int type = sc.nextInt();
    switch(type){
    case 1:Login();break;
    case 2:Login_user();break;
    default:System.exit(0);
    }
}
public static User Login() throws SQLException{
    System.out.println("*********************************");
    System.out.print("输入用户名:");
    Scanner sc = new Scanner(System.in);
    //如果用户名为主键,需要对用户名是否重复进行判断
    String in_user = sc.nextLine();
    while(UserDao.judgeName(in_user)==-1){
        System.out.println("用户名重复");
        System.out.println("请重新输入注册用户名:");
        in_user = sc.nextLine();
    }
    System.out.print("输入密码:");
    String psd = sc.nextLine();
    //调用userDao完成注册写入
    User user = new User();
    user.setName(in_user);
    user.setPsd(psd);
    UserDao.LoginUser(user);
    System.out.print("注册成功,将跳转首页\t\t");
    index(user);
    return user;
}
public static void Login_user(){
    System.out.println("\n*********************************");
    System.out.print("输入用户名:");
    Scanner sc = new Scanner(System.in);
    //如果用户名为主键,需要对用户名是否重复进行判断
    String in_user = sc.nextLine();
    System.out.print("输入密码:");
    String in_psd = sc.nextLine();
    //调用userDao完成用户身份确认
    //成功则model记录,跳转到首页,否则失败重新调用当前函数。
    
}
public static void index(User user){
    System.out.println(up);
    System.out.println("*欢迎"+user.getName()+"访问本系统");
    System.out.println("*1.查询想要购买的商品信息");
    System.out.println("*2.查询购物车信息");
    System.out.println("*3.查询已购买订单");
    System.out.println("*4.查询个人用户信息");
    System.out.println("*5.小游戏攒积分");
    Scanner sc = new Scanner(System.in);
    int type = sc.nextInt();
    switch(type){
    case 1:;break;
    case 2:;break;
    case 3:;break;
    case 4:;break;
    case 5:;break;
    default:break;
    }
}
public static void main(String[] args) throws SQLException {
    // TODO Auto-generated method stub
    MainMenu();
}

} package com.model;

public class User { private String name; private String psd; public User(String name,String psd){ this.name = name; this.psd = psd; } public User(){

}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public String getPsd() {
    return psd;
}
public void setPsd(String psd) {
    this.psd = psd;
}

} package com.model;

public class Book { private String bookname;//书名 private String author;//书作者 private int bookid;//书编号

public Book(int bookid,String bookname,String author){
    super();
    this.bookid=bookid;
    this.bookname=bookname;
    this.author=author;
    
}
public Book(){
    super();
}

public String getBookname() {
    return bookname;
}
public void setBookname(String bookname) {
    this.bookname = bookname;
}
public String getAuthor() {
    return author;
}
public void setAuthor(String author) {
    this.author = author;
}
public int getBookid() {
    return bookid;
}
public void setBookid(int bookid) {
    this.bookid = bookid;
}

}

  • 写回答

2条回答 默认 最新

  • CSDN专家-sinJack 2021-06-30 19:48
    关注

    大体功能已经出来了,就是具体方法的实现。增删改查的操作而已。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答