package fytfyt;
import java.util.*;
public class Firstlq {
static ArrayList newlist = new ArrayList();
public static Scanner input = new Scanner(System.in);
public static void stratNume()
{
System.out.println("——------------------------");
System.out.println("欢迎使用江西工程学院图书管理系统");
System.out.println("---------------------------");
System.out.println("请输入你的选择1,用户登录 2 注册用户 0退出系统 ");
Scanner input = new Scanner(System.in);
int a = input.nextInt();
switch(a)
{ case 1:
System.out.println("欢迎进入注册界面");
register();
break;
case 2:
System.out.println("欢迎进入登录界面");
login();
break;
case 3:
System.out.println("欢迎进入退出界面");
returnback();
break;
default :
System.out.println("没搞错,数都不会输入。你猪头");
break;
}
}
public static void register(){
boolean isSus = false;
do
{
System.out.println("欢迎进入注册界面");
System.out.println("请你输入你注册的用户名");
String username = input.next();
String reg = "[a-zA-Z][129][1-9]{4}"
;
boolean isusername =username.matches( reg);
if (isusername){
System.out.print("合法用户名");
}else {
register();
}
System.out.println("请输入你的注册密码");
String packword = input.next();
//增加一个Object来存储输入的用户名和名字
Person p2 = new Person(username,packword);
//增加一个判断用户名是否存在
// void cheakregister();
ArrayList list = new ArrayList();
Person p = new Person("李四","123456");
list.add(p);
Person p1 = new Person("张三","234567");
list.add(p1);
if (list.contains(p2)){
System.out.println("用户名已经存在,改名吧");
isSus = true;
}
newlist.addAll(list);
}
while(isSus);
}
public static void login(){
System.out.println("欢迎进入登录界面");
System.out.println("请你输入你的用户名");
String username = input.next();
System.out.println("请输入你的密码");//密码和用户怎么和list里面的一样。
String packword = input.next();
Person p3 = new Person(username,packword);
if (newlist.contains(p3)){
System.out.println("成功");
//调用一个方法来解决选择你要干嘛。
}else {System.out.println("密码用户不正确,");}
//调用一个还回菜单
}
//调一个方法,来判断是否登录成功
public static void returnback(){
stratNume();
return;
}
public void showBook(ArrayList list){
System.out.println(list);
}
}
class Person{
private String name;
private String packword;
public Person(String name,String packword){
this.name = name;
this.packword = packword;
}
}
class libraryTest
{
static ArrayList list2 = new ArrayList();
public static void main(String[] args){
Firstlq n = new Firstlq();
n.stratNume();
ArrayList list1 = new ArrayList();
Book book = new Book("javaweb入门","张三","清华出版社","89.0","1234560","2010-10-1");
Book book1 = new Book("javaEE项目实践","李四","机械工业出版社","189.0","1234561","2010-10-2");
Book book2 = new Book("XmL入门","张三","清华出版社电力出版社","89","1234562","2010-10-3");
Book book3 = new Book("java基础入门","王五","北大出版社","50.0","1234563","2010-10-4");
list1.add(book);
list1.add(book1);
list1.add(book2);
list1.add(book3);
Firstlq f = new Firstlq();
//调用一个展示图书的方法。
f.showBook(list1);
list2.addAll(list1);
//调用一个增加图书的方法}
addlibrary();
}
public static void addlibrary(){
Scanner input = new Scanner(System.in);
System.out.println("请输入你要增加的图书的名字");
String a = input.next();
System.out.println("请输入你要增加的图书的作者");
String b = input.next();
System.out.println("请输入你要增加的图书的出版社");
String c = input.next();
System.out.println("请输入你要增加的图书的价格");
String d = input.next();
System.out.println("请输入你要增加的图书的编号");
String e = input.next();
System.out.println("请输入你要增加的图书的日期");
String f = input.next();
System.out.println("Book"+a+"autor"+b+"press"+c+"price"+d+"bookNumber"+e+"pressdate"+f);
System.out.println("添加图书中,请耐心等待...");
//添加图书
//把所有的信息填入到集合中去
Book book1 = new Book(a,b,c,d,e,f);
list2.add(book1);
System.out.println("添加成功");
//展示你的图书的方法。
Firstlq f1 = new Firstlq();
f1.showBook(list2);
}
}
class Book
{
String bookName;
String autor;
String press;
String price;
String bookNumber;
String pressdate;
public Book(String bookName,String autor,String press,String price,String bookNumber,String pressdate){
this.bookName = bookName;
this.autor = autor;
this.press = press;
this.price = price;
this.bookNumber = bookNumber;
this.pressdate = pressdate;
}
}
图书馆管理系统
最新推荐文章于 2022-11-18 19:59:38 发布