/** * This method checks if memberId already exists -- if so, it cannot be added as a new member, and * an exception is thrown. If new, creates a new LibraryMember based on input data and uses * DataAccess to store it. * * @throws Exception */ public void addNewMember( String memberId, String firstName, String lastName, String telNumber, Address addr) throws Exception { DataAccess dataAccess = new DataAccessFacade(); HashMap<String, LibraryMember> memberMap = dataAccess.readMemberMap(); if (!memberMap.containsKey(memberId)) { memberIdError.setText(""); service.saveMember(new LibraryMember(memberId, firstName, lastName, telNumber, addr)); } else { memberIdError.setText("Member with Id# " + memberID.getText() + " already exists!"); } }
@Override public void initialize(URL location, ResourceBundle resources) { TestData td = new TestData(); td.bookData(); td.libraryMemberData(); td.userData(); DataAccess da = new DataAccessFacade(); System.out.println(da.readBooksMap()); System.out.println(da.readUserMap()); System.out.println(da.readMemberMap()); }