Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. package librarymanager;
  2.  
  3. import librarymanager.LibraryManager.Author;
  4.  
  5. /*
  6. * To change this license header, choose License Headers in Project Properties.
  7. * To change this template file, choose Tools | Templates
  8. * and open the template in the editor.
  9. */
  10.  
  11. /**
  12. *
  13. * @author admin
  14. */
  15. public class Library
  16. {
  17. private Author[] authorsList;
  18.  
  19. private void createNewAuthorsList()
  20. {
  21.  
  22. }
  23.  
  24.  
  25. private int getNexAuthorID()
  26. {
  27. int retvalue = 0; //variablile che contiene il valore di authorID piu alto, trovato
  28. try
  29. {
  30. for(int i = 0; i <this.authorsList.length;i++)
  31. {
  32. if(this.authorsList[i].getAuthorID() > retvalue)
  33. {
  34. retvalue = this.authorsList[i].getAuthorID();
  35. }
  36. }
  37. }
  38. catch(ArrayIndexOutOfBoundsException e)
  39. {
  40.  
  41. }
  42. return retvalue + 1;
  43. }
  44.  
  45.  
  46. public int isAuthorPresent(String name, String surname, String birthData)
  47. {
  48. int retvalue = -1;
  49.  
  50. for(int i = 0; i < this.authorsList.length; i ++)
  51. {
  52.  
  53. if (name.equals(this.authorsList[i].getName()) && surname.equals(this.authorsList[i].getSurname()) && birthData.equals(this.authorsList[i].getBirthData()))
  54. {
  55. retvalue = i;
  56. break;
  57. }
  58.  
  59. }
  60.  
  61. return retvalue;
  62. }
  63.  
  64. public boolean addAuthor( String name, String surname, char sex, String birtDate,String beathData, String shortBio, String country )
  65. {
  66. if (this.isAuthorPresent(name, surname, beathData) == -1)
  67. {
  68. //Autore non trovato nell'Array: insaerito
  69.  
  70. //FASE 1: trovare il prossimo AuthorID valido
  71. int nexAuthorID = this.getNexAuthorID();
  72. }
  73. else
  74. {
  75. //TODO: gestire il campo di autore gia inserito procedentemente
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement