wm: java

Download patch

ref: 48e2e0e38472ce670c97a2e0bcbebcaca2572823
parent: c29750ceb403bfaa8716480b6fdf06f578db21a9
author: mkf <mkf@d510>
date: Fri May 26 07:52:16 EDT 2023

so long, old partner

--- a/Main.java
+++ b/Main.java
@@ -9,9 +9,14 @@
 import java.util.Scanner;
 */
 import java.util.*;
-import java.time.*;
-import java.util.regex.*;
+import java.time.LocalDateTime;
+
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
 import java.io.Console;
+import java.io.File;
+
 enum Role
 {
 	Admin,
@@ -72,7 +77,7 @@
 
 	boolean CheckUser(String u);
 	User MatchUser(String un);
-	boolean FindUser(String un);
+	boolean FindUser(UserAttr k, Pattern q);
 
 	/* books */
 	void TakeBook(String un, String isbn);
@@ -395,10 +400,16 @@
 class Lib implements Library
 {
 	/* Username, Admin/User, ISBN, Book */
+	
 	private HashMap<String, Admin> AdminList = new HashMap<String, Admin>();
 	private HashMap<String, User> UserList = new HashMap<String, User>();
 	private HashMap<String, Book> BookList = new HashMap<String, Book>();
-
+/*
+	private HashMap<String, HashMap> AdminList = new HashMap<String, HashMap>;
+	private HashMap<String, HashMap> UserList = new HashMap<String, HashMap>;
+	private HashMap<String, HashMap> BookList = new HashMap<String, HashMap>;
+	private HashMap<String, HashMap> = new HashMap<String, HashMap>;
+*/
 	private ArrayList<Admin> AdminQuery = new ArrayList<Admin>();
 	private ArrayList<User> UserQuery = new ArrayList<User>();
 	private ArrayList<Book> BookQuery = new ArrayList<Book>();
@@ -517,18 +528,25 @@
 	/* should there be checks */
 	public Book NewBook(String isbn, String name, String author, String abst, int agegroup)
 	{
+		for(Book b : this.BookList.values())
+		{
+			if(b.getISBN().equals(isbn))
+			{
+				throw new IllegalStateException("Book already exist");
+			}
+		}
+
 		Book b = new Book(name, author, abst, isbn, agegroup);
 		this.BookList.put(isbn, b);
 		return b;
 	}
 
-
 	public void DelBook(Book b)
 	{
 		if(!b.getOwner().isEmpty())
 		{
-			System.err.println("User " + b.getOwner() + " have reserved this book.");
-			return;
+			// System.err.println("User " + b.getOwner() + " have reserved this book.");
+			throw new IllegalStateException("Book is reserved.");
 		}
 		this.BookList.remove(b.getISBN());
 	}
@@ -685,6 +703,10 @@
 			throw new NoSuchElementException("No such User exists.");
 		}
 		return u;
+	}
+	public boolean FindUser(UserAttr k, Pattern q)
+	{
+
 	}
 
 	public boolean FindBook(boolean q)