Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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.
- */
- package librarymanager;
- import librarymanager.Exception.InvalidSurnameException;
- import librarymanager.Exception.InvalidShortBioException;
- import librarymanager.Exception.InvalidSexException;
- import librarymanager.Exception.InvalidBeathDataException;
- import librarymanager.Exception.InvalidCountryException;
- import librarymanager.Exception.InvalidBirthDataException;
- import librarymanager.Exception.InvalidNameException;
- import librarymanager.Exception.InvalidAuthorIdException;
- /**
- *
- * @author admin
- */
- public class LibraryManager
- {
- public class Author
- {
- private String name;
- private String surname;
- private char sex;
- private String birthData;
- private String beathData;
- private String shortBio;
- private String country;
- private int authorID;
- public Author( String name, String surname, char sex, String birtDate,String beathData, String shortBio, String country ,int newAuthorID)
- throws InvalidNameException, InvalidSurnameException, InvalidSexException, InvalidBirthDataException, InvalidBeathDataException, InvalidShortBioException, InvalidCountryException, InvalidAuthorIdException
- {
- this.setName(name);
- this.setSurname(surname);
- this.setSex(sex);
- this.setBirthData(birthData);
- this.setBeathData(beathData);
- this.setShortBio(shortBio);
- this.setCountry(country);
- this.setAuthorID(newAuthorID);
- }
- public int getAuthorID ()
- {
- return this.authorID;
- }
- public String getName()
- {
- return name;
- }
- public String getSurname()
- {
- return surname;
- }
- public char getSex()
- {
- return sex;
- }
- public String getBirthData()
- {
- return beathData;
- }
- public String getShortBio()
- {
- return shortBio;
- }
- public String getCountry()
- {
- return country;
- }
- public void setName(String newName) throws InvalidNameException
- {
- if (newName.length() > 1)
- {
- this.name = newName;
- }
- else
- {
- InvalidNameException e = new InvalidNameException("Invalid Name");
- throw e;
- }
- }
- public void setSurname(String newSurname) throws InvalidSurnameException
- {
- if(newSurname.length() > 2)
- {
- this.surname = newSurname;
- }
- else
- {
- InvalidSurnameException e = new InvalidSurnameException("Invalid Surname");
- throw e;
- }
- }
- public void setSex(char newSex) throws InvalidSexException
- {
- if(newSex == 'm' || newSex == 'f')
- {
- this.sex = newSex;
- }
- else
- {
- InvalidSexException e = new InvalidSexException("Invalid Sex");
- throw e;
- }
- }
- public void setBirthData(String newBirthData) throws InvalidBirthDataException
- {
- if(newBirthData.length() > 100)
- {
- this.birthData = newBirthData;
- }
- else
- {
- InvalidBirthDataException e = new InvalidBirthDataException("Invalid BirthData");
- throw e;
- }
- }
- public void setBeathData(String newBeathData) throws InvalidBeathDataException
- {
- if(newBeathData.length() > 100)
- {
- this.beathData = newBeathData;
- }
- else
- {
- InvalidBeathDataException e = new InvalidBeathDataException("Invalid BeathData");
- throw e;
- }
- }
- public void setShortBio(String newShortBio) throws InvalidShortBioException
- {
- if(newShortBio.length() > 2 && newShortBio.length() <= 10000)
- {
- this.shortBio = newShortBio;
- }
- else
- {
- InvalidShortBioException e = new InvalidShortBioException ("ShortBio length must be > 2 and < 10000");
- throw e;
- }
- }
- public void setCountry(String newCountry) throws InvalidCountryException
- {
- if(newCountry.length() > 3)
- {
- this.country = newCountry;
- }
- else
- {
- InvalidCountryException e = new InvalidCountryException("Country is too short");
- throw e;
- }
- }
- public void setAuthorID( int newAuthorID) throws InvalidAuthorIdException
- {
- if(newAuthorID.length() > 0 )
- {
- this.authorID = newAuthorID;
- }
- else
- {
- InvalidAuthorIdException e = new InvalidAuthorIdException("Invalid AuthorId");
- throw e;
- }
- }
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args)
- {
- // TODO code application logic here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement