JAVA CLASSES

profileBadshah
Test.java

import edu.cudenver.app.App; import edu.cudenver.library.Author; import edu.cudenver.library.Book; import edu.cudenver.library.Publisher; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.PrintStream; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; public class Test{ public static void test1(){ try{ System.setIn(new FileInputStream("in.txt")); // System.setOut(new PrintStream(new FileOutputStream("out.txt"))); App.main(new String[1]); } catch (FileNotFoundException fnfe){ System.out.println("File Not Found." + fnfe); } } public static double test2(){ ArrayList<Author> authorList = new ArrayList<>(); ArrayList<Publisher> publisherList = new ArrayList<>(); ArrayList<Book> bookList = new ArrayList<>(); String line, returnedText; double score = 0; int tests=0; tests++; line = "A|Deitel Deitel"; returnedText = App.scan(line,authorList,publisherList,bookList); if (returnedText.equals("Deitel Deitel is an Author")) score++; tests++; line = "P|Pearson|Denver"; returnedText = App.scan(line,authorList,publisherList,bookList); if (returnedText.equals("Publisher 'Pearson' at 'Denver'")) score++; tests++; line = "B|Java Programming|Shelf4|2010|Deitel Deitel|Pearson"; returnedText = App.scan(line,authorList,publisherList,bookList); if (returnedText.equals("A book called 'Java Programming' written by 'Deitel Deitel' and published in 2010 by 'Pearson'")) score++; return score/tests; } public static double test3(){ double score = 0; int tests=0; tests++; //This is intentionally wrong, just for demonstration purposes. if ( (new Author("John Smit")).toString().equals("John Smith is an Author")) score++; return score/tests; } public static void main(String[] args){ double scores=0; double score=0; int tests=0; test1(); score=test2();scores += score; tests++; System.out.printf("Running Test 2... Got Score %10.2f%n",score); score=test3(); scores += score; tests++; System.out.printf("Running Test 3... Got Score %10.2f%n",score); System.out.printf("++ Final Score:%3d%n",(int)(scores*100)/tests); } }