if (command.equals("addMagazine")) {
String magazineName = input.next();
ArrayList<Paper> listOfPapers = new ArrayList<Paper>();
// build papers list
listOfPapers.add(new Paper("paper1", Topic.CS, new Author("author5Name", "author5LastName", Topic.CS), PaperValue.CONFERENCE,"Haifa university" ));
System.out.printf("papers.0 is not null: %b%n", listOfPapers.get(0));
listOfPapers.add(new Paper("paper2", Topic.MATH,new Author("author6Name", "author6LastName", Topic.MATH), PaperValue.MAGAZINE,"MIT university" ));
System.out.printf("papers.1 is not null: %b%n", listOfPapers.get(1));
listOfPapers.add(new Paper("paper3", Topic.CHEMISTRY,new Author("author7Name", "author7LastName", Topic.CHEMISTRY), PaperValue.WORK_SHOP,"Oxford university" ));
System.out.printf("papers.2 is not null: %b%n", listOfPapers.get(2));
listOfPapers.add(new Paper("paper4", Topic.SOCIOLOGY,new Author("author8Name", "author8LastName", Topic.SOCIOLOGY), PaperValue.CONFERENCE,"Tel Aviv university" ));
System.out.printf("papers.3 is not null: %b%n", listOfPapers.get(3));
listOfPapers.add(new Paper("paper5", Topic.CS,new Author("author5Name", "author5LastName", Topic.CS), PaperValue.MAGAZINE,"haifa university" ));
System.out.printf("papers.4 is not null: %b%n", listOfPapers.get(4));
listOfPapers.add(new Paper("paper6", Topic.PHYSICS,new Author("author9Name", "author9LastName", Topic.PHYSICS), PaperValue.CONFERENCE,"Yael university" ));
System.out.printf("papers.5 is not null: %b%n", listOfPapers.get(5));
int id = 2;
//create magazine
Magazine magazine = new Magazine(magazineName, id, listOfPapers);
System.out.printf("papers.6 is not null: %b%n", magazine);
// add to library
if (LibrarySys.addMagazine(magazine)) { // if adding successfully, then true returned,
// the following message is written to the output file
System.out.printf("papers.7 is not null: %b%n", magazine);
MyFileLogWriter.writeToFileInSeparateLine("Successfully adding magazine: " + magazineName );
} else {
MyFileLogWriter.writeToFileInSeparateLine("Failed to add magazine review");
}
}
// ================ Building Command ================================================
if (command.equals("getMagazinePapers")) {
String magazineName = input.next();
Magazine magazine = LibrarySys.getMagazine(magazineName);
System.out.printf("papers.8 is not null: %b%n", magazine);
if (magazine == null)
MyFileLogWriter.writeToFileInSeparateLine("no magazine with this name");
else
MyFileLogWriter.writeToFileInSeparateLine(LibrarySys.getMagazinePapers(magazine).toString());
}