JAVA CLASSES

profileBadshah
App.java

package edu.cudenver.app; import edu.cudenver.library.Author; import edu.cudenver.library.Book; import edu.cudenver.library.Publisher; import java.util.ArrayList; import java.util.Scanner; public class App { /** * Main Application. Uses the library package. * @see edu.cudenver.library * @see edu.cudenver.library.Author * @see edu.cudenver.library.Book * @see edu.cudenver.library.Publisher */ public static void main(String[] args){ System.out.println("Creating two authors (John and Luke) and one publisher (Pearson)"); //TODO: #1 // Create an Author called John // Create an author called Luke // Create a publisher called Pearson /* Add Code Here */ //TODO: #2 // Print the two authros and the publisher to the std. output. /* Add Code Here */ System.out.printf("Creating one book%n"); //TODO: #3 //Create a book titled "The World of Java", located on "Shelf#3" published in 1999. //The author is John and published by pearson. //As soon as you created the book, print the book. //Also print the string: Book:<book title> author is <book author name>. /* Add Code Here */ //TODO: #4 //Check if the object for the book author you just created is the same author object for John //you created in task #1. If it is print a line with the text "Objects Match" if not, review your code, it //should match! /* Add Code Here */ //TODO: #5 // Create an array list to store Authors called authorList // Create an array list to store Publishers called publisherList // Create an array list to store Books called bookList /* Add Code Here */ ///// Scanner input = new Scanner(System.in); while(input.hasNextLine()) { String line = input.nextLine(); System.out.println(scan(line,authorList,publisherList,bookList)); } } //Todo: #6: Complete the data type for the arrays. public static String scan(String line, /*here - remove this comment*/ authorList, /*here - remove this comment*/ publisherList, /*here - remove this comment*/ bookList){ /* TODO: #7 <> The line will be delimited by the character | (review String.split and Pattern: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html The first field identifies the object type. A for an author, P for a publisher and B for a book. Formatting of the input: Author: A|author name\n (note: \n represents end of line) e.g. A|John\n A|Alice\n Publisher: P|Publisher name|Publisher address\n e.g. P|Pearson|Denver\n P|Oreilly|Unknown\n Book: B|title|location|publication year|author name|publisher name\n e.g. B|The world of Java|Shelf_3|1999|John|Pearson\n <> For each line you will be creating a new object and storing it into the corresponding ArrayList parameter. <> Once you created the object and added to the array, you need to return the object default display string. <> For books, you will not create new authors and publishers. You need to search in your author/publisher list for the matching author/publisher based on the name. If you can't find the author or publisher, return the string "Error" and skip the line (don't add anything to the array). */ /* Add Code Here */ //If we reach this point, return Error return "Error"; } }