Advertisement
Guest User

1class

a guest
May 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 KB | None | 0 0
  1. import javax.naming.Name;
  2. import java.rmi.Naming;
  3. import java.util.List;
  4. import java.util.Scanner;
  5.  
  6. public class Library
  7. {
  8.  
  9.     List[]Books;
  10.     String Name;
  11.  
  12.    public String getName()
  13.     {
  14.         return Name;
  15.     }
  16.  
  17.    public void setName(String name)
  18.     {
  19.         Name = name;
  20.     }
  21.  
  22.     public List[] getBooks()
  23.     {
  24.         return Books;
  25.     }
  26.  
  27.     public void setBooks(List[] books)
  28.     {
  29.         Books = books;
  30.     }
  31.  
  32.     public void NewBook()
  33.     {
  34.         Scanner sc = new Scanner(System.in);
  35.         System.out.println("Въведете книга: ");
  36.         System.out.println("Име: ");
  37.         Name = sc.nextLine();
  38.     }
  39.  
  40.     public void FindBook()
  41.     {
  42.         Scanner sc = new Scanner(System.in);
  43.         System.out.println("Въведете автор на книга: ");
  44.         String Author;
  45.         Author = sc.nextLine();
  46.         for(int i = 0; i < Books.length; i++)
  47.         if(Author.equals(Books[i].Author))
  48.         {
  49.             System.out.println("Книга: " + Books[i]);
  50. }
  51.  
  52. static void DelBook()
  53.         {
  54.             Scanner scanner = new Scanner(System.in);
  55.             String DelOrNot;
  56.             System.out.println("Искате ли да изтриете книга?");
  57.             DelOrNot = scanner.nextLine();
  58.             if(DelOrNot.equals("yes"))
  59.             {
  60.                 Books.remove(i);
  61.             }
  62.         }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement