Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package librarymanager;
- import librarymanager.LibraryManager.Author;
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author admin
- */
- public class Library
- {
- private Author[] authorsList;
- private void createNewAuthorsList()
- {
- }
- private int getNexAuthorID()
- {
- int retvalue = 0; //variablile che contiene il valore di authorID piu alto, trovato
- try
- {
- for(int i = 0; i <this.authorsList.length;i++)
- {
- if(this.authorsList[i].getAuthorID() > retvalue)
- {
- retvalue = this.authorsList[i].getAuthorID();
- }
- }
- }
- catch(ArrayIndexOutOfBoundsException e)
- {
- }
- return retvalue + 1;
- }
- public int isAuthorPresent(String name, String surname, String birthData)
- {
- int retvalue = -1;
- for(int i = 0; i < this.authorsList.length; i ++)
- {
- if (name.equals(this.authorsList[i].getName()) && surname.equals(this.authorsList[i].getSurname()) && birthData.equals(this.authorsList[i].getBirthData()))
- {
- retvalue = i;
- break;
- }
- }
- return retvalue;
- }
- public boolean addAuthor( String name, String surname, char sex, String birtDate,String beathData, String shortBio, String country )
- {
- if (this.isAuthorPresent(name, surname, beathData) == -1)
- {
- //Autore non trovato nell'Array: insaerito
- //FASE 1: trovare il prossimo AuthorID valido
- int nexAuthorID = this.getNexAuthorID();
- }
- else
- {
- //TODO: gestire il campo di autore gia inserito procedentemente
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement